Hello everyone,
I am really having a lot of trouble understanding the DOM and I doing
something quite basic. I need to the DOM (in PHP 5) to modify an XML
file. For example the XML basically looks like this.
<news>
<pageContent>
<heading></heading>
<author></author>
</pageContent>
<commentSection >
</commentSection>
</news>
What I am trying to do is simple add nodes and content within
<commentSection > and </commentSection> tags. I have been trying the
DOM PHP 5 functions, but I cannot get it quite right. What are the
functions and order would I use if I wanted to take the above XML file
and modify it to look like this:
<news>
<pageContent>
<heading></heading>
<author></author>
</pageContent>
<commentSection >
<comment>
<user>joe</user>
<date>some date</date>
</comment>
<comment>
<user>john</user>
<date>some date</date>
</comment>
</commentSection>
</news>
My big issue is that I cannot get the tags to close in the right place.
If someone could please include a snippet of code that would show me
how to modify the XML file as above, I would really appreciate it.
Right now, I can't find my mistake. Thank you!