PERL XML::LibXML changes tag structure when outputting XML

Flowers

New Member
THE SITUATIONAfter I have edited an XML and changed the values successfully, I need to write the changes back to the file. However, when I do this, the first tag of the XML, which has two attributes (a) date_time and (b) xmlns:xsi gets switched around after the uodate. The following is the sample of the XML:XML Document sampleTHE ORIGINAL XML \[code\]<?xml version="1.0" encoding="UTF-8"?><basenet date_time="201202131140" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ><msg_ver>01</msg_ver><sender_id>1234</sender_id><recipient_id>Bob</recipient_id> </basenet>\[/code\]The Output\[code\]<?xml version="1.0" encoding="UTF-8"?><tradenet xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" date_time="201202131140"><msg_ver>01</msg_ver><sender_id>1234</sender_id><recipient_id>Bob</recipient_id> </tradenet>\[/code\]The Code\[code\] sub CHANGE_DATE_SEQ_NUM() {# loadopen my $fh, '<', $newfile;binmode $fh; # drop all PerlIO layers possibly created by a use open pragmamy $doc = XML::LibXML->load_xml(IO => $fh); my $query = "/tradenet/message/header/unique_ref_no/date/text( )"; my $query2 = "/tradenet/message/header/unique_ref_no/seq_no/text( )"; my $query3 = "/tradenet/message/transport/out_tpt/dept_date/text( )"; #print $query3; my($node) = $doc->findnodes($query); my($node2) = $doc->findnodes($query2); my($node3) = $doc->findnodes($query3); $node->setData("$date"); $node2->setData("$file_seq_number"); $node3->setData("$date"); # save open my $out, '>', $newfile; binmode $out; # as above $doc->toFH($out); }\[/code\]My QuestionWhy does the date_time and xmlns:xsi in the tag get switched? The switch is causing my XML to fail the validation at my server side.Thank you for you time.
 
Top