I’ve got an xml output self-generated from a cms (drupal)
I need to work on this xml, but the automatic output generate a lot of useless nodes, and i need to erase them.
This is a sample similar to the original XML i’ve got to modify (a very semplified version, of course)
<node>
<title>AAAAAA</title>
<category>1</category>
<description>blablabla</description>
</node>
<node>
<title>ZZZZZ</title>
<category>7</category>
<description>blablabla</description>
</node>
<node>
<title>XXXXXXXX</title>
<category>5</category>
<description>blablabla</description>
</node>
<node>
<title>BBBBBBB</title>
<category>1</category>
<description>blablabla</description>
</node>
<node>
<title>CCCCCCCCC</title>
<category>1</category>
<description>blablabla</description>
</node>
<node>
<title>YYYYYYYY</title>
<category>4</category>
<description>blablabla</description>
</node>
Let’s suppose to have a check on the category, i want to keep only the nodes with category 1.
All i need to do is to parse the xml recognizing a certain tag (for example )
and erase all the useless information, in order to have something like this example.
<node>
<title>AAAAAA</title>
<category>1</category>
<description>blablabla</description>
</node>
<node>
<title>BBBBBBB</title>
<category>1</category>
<description>blablabla</description>
</node>
<node>
<title>CCCCCCCCC</title>
<category>1</category>
<description>blablabla</description>
</node>
The idea is: check a certain tag, and keep all the information in the node…
How can I do something like this?
I suppose I’ve got to use something like DOM.
I’d prefer to use php, but also java is welcome.
Consider the following example: