include xml file in another xml file

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
devendra-m
Forum Contributor
Posts: 111
Joined: Wed Sep 12, 2007 3:16 am

include xml file in another xml file

Post by devendra-m »

I have an xml file book.xml as

Code: Select all

<book>
    testbook
</book>
 
I want to include book.xml in test.xml so I used following method.

test.xml

Code: Select all

<?xml version="1.0"?>
<!DOCTYPE novel  [
<!ENTITY book SYSTEM "book.xml">
]>
<test>
     &book;
</test>


and i got the output as

Code: Select all

<test>
      <book>
              <book>
                        testbook
             </book>
      </book>
</test>
>

there is extra tag included in test.xml

but the desired output is

Code: Select all

<test>
             <book>
                        testbook
             </book>
</test>
can anybody help to achieve this
User avatar
JNettles
Forum Contributor
Posts: 228
Joined: Mon Oct 05, 2009 4:09 pm

Re: include xml file in another xml file

Post by JNettles »

Load the XML files into a string and concat them/str_replace as necessary. Then output.
Post Reply