I asked a similar question last week but did not get an answer that really nailed it. I suspect the question needs to be stated more plainly so here goes:
Given this XML:
<?xml version="1.0" encoding="utf-8"?>
<everyone>
<guest>
<name>Joseph Needham</name>
<age>53</age>
</guest>
<guest>
<name>Lu Gwei-djen</name>
<age>31</age>
</guest>
</everyone>
How do I return precisely this:
<guest>
<name>Joseph Needham</name>
<age>53</age>
</guest>
<guest>
<name>Lu Gwei-djen</name>
<age>31</age>
</guest>
I don't want a simplexml object, I don't want to convert anything, I don't want just the values of nodes, I don't want a new XML document with its corresponding header... just that chunk of XML. Can't use external libraries... nothing that doesn't come with a standard, average PHP install. How do I extract one out of the other?
My best guess? Use DomDocument to get the nodes names and content somehow and then rebuild what I want by using a foreach loop and echoing out the various node names and values including line endings to format everything properly. However, this seems like it could be amazingly clunky. I suspect there is a simpler way to do it so I want to see if anyone here on stackoverflow know what that way is (or can tell me that there is, in fact, NOT an easier way). Thanks in advance.