in reply to Append in XML using perl
In this I want to add a new node in the last or want to edit the note or delete the node.<?xml version="1.0" encoding="windows-1252"?> <IDList><Details><id>Trial ID</id><name>Mooza </name></Details><Details><id>Trial ID</id><name>bin_salim99 </name></Details><Details><id>Trial ID</id><name>dino88 </name></Details><Details><id>Trial ID</id><name>al3neeeeed </name></Details><Details><id>TrialID</id><name>Do0oDa</name></Details +></IDList>
Now I want to add a new child in the xml file or edit a node or delete the node. How i can do it and give some suggestions for that. If have any code send it.use XML::Writer; use XML::XPath; use XML::XPath::Node; use IO::File; open(NEW, "<<../main/idno.txt"); @id = <NEW>; close (NEW); my $output = new IO::File(">data9.xml"); my $doc = XML::Writer->new(OUTPUT => $output); $doc->xmlDecl("windows-1252"); $doc->startTag("IDList"); foreach (@id) { ($actid, $name) = split(/:/, $_); $doc->startTag( "Details" ); $doc->dataElement( id => $actid); $doc->dataElement( name => $name); $doc->endTag("Details"); } $doc->endTag("IDList"); # close IDList $doc->end(); # final checks $output->close();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Editing in xml
by gellyfish (Monsignor) on Jun 07, 2006 at 14:00 UTC | |
by antovinraj (Initiate) on Jun 08, 2006 at 07:04 UTC | |
by gellyfish (Monsignor) on Jun 08, 2006 at 07:35 UTC | |
|
Re: Editing in xml
by liverpole (Monsignor) on Jun 07, 2006 at 10:59 UTC |