shanu_040 has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks,
I have an XML file with following dummy data. Seeking help on how to remove an element from XML file using XML::LibXML.
Condition to remove element
If value of uid is equal to input value then remove corresponding document element.
<searchresult> <document id="3404"> <uid>16b3</uid> <title><![CDATA[Title1]]></title> <author><![CDATA[Author1]]></author> <date><![CDATA[2010]]></date> <source><![CDATA[Source1]]></source> <volume><![CDATA[1]]></volume> <issue><![CDATA[1]]></issue> <snippet><![CDATA[Snippet]]></snippet> <abstract_url><![CDATA[http://yourhost.com/ar1]]></abstract_url> <fulltext_url><![CDATA[http://yourhost.com/ft1]]></fulltext_url> <resource> <longname><![CDATA[Name1]]></longname> </resource> <nativesearch_url><![CDATA[http://yourhost.com/n1]]></nativesearch_url +> </document> <document id="3404"> <uid>3cdd</uid> <title><![CDATA[Title2]]></title> <author><![CDATA[Author2]]></author> <date><![CDATA[2010]]></date> <source><![CDATA[Source2]]></source> <volume><![CDATA[2]]></volume> <issue><![CDATA[2]]></issue> <snippet><![CDATA[Snippet]]></snippet> <abstract_url><![CDATA[http://yourhost.com/ar1]]></abstract_url> <fulltext_url><![CDATA[http://yourhost.com/ft1]]></fulltext_url> <resource> <longname><![CDATA[Name1]]></longname> </resource> <nativesearch_url><![CDATA[http://yourhost.com/n1]]></nativesearch_url +> </document> <document id="3404"> <uid>446d</uid> <title><![CDATA[Title1]]></title> <author><![CDATA[Author1]]></author> <date><![CDATA[2010]]></date> <source><![CDATA[Source1]]></source> <volume><![CDATA[1]]></volume> <issue><![CDATA[1]]></issue> <snippet><![CDATA[Snippet]]></snippet> <abstract_url><![CDATA[http://yourhost.com/ar1]]></abstract_url> <fulltext_url><![CDATA[http://yourhost.com/ft1]]></fulltext_url> <resource> <longname><![CDATA[Name1]]></longname> </resource> <nativesearch_url><![CDATA[http://yourhost.com/n1]]></nativesearch_url +> </document> </searchresult>
Any help would be greatly appreciated.
Thanks
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Deleting XML element using XML::LibXML
by ikegami (Patriarch) on Sep 14, 2010 at 23:51 UTC | |
|
Re: Deleting XML element using XML::LibXML
by marto (Cardinal) on Sep 14, 2010 at 12:18 UTC | |
|
Re: Deleting XML element using XML::LibXML
by graff (Chancellor) on Sep 14, 2010 at 23:10 UTC | |
|
Re: Deleting XML element using XML::LibXML
by choroba (Cardinal) on Sep 14, 2010 at 13:11 UTC |