tobias_hofer has asked for the wisdom of the Perl Monks concerning the following question:
Hello Monks.
I am using XML::Simple for xml processing.
I read in following from a file:
So in the end i got this:
I am stuck in the middle, any help is highly welcome!
Here my prototype where i read in the an xml-file with the content of the first XML-structure i have put here. By this i can check if (at the end) i will get the same XML-structure back when looking at $xml:
Any help is highly welcome!
Regards!
Tobias
I am using XML::Simple for xml processing.
I read in following from a file:
And I want to write the same to file. Thing is, that when i am putting the xml to file some values become xml-attributes.<TABLE> <TABLE-CAPTION ID="ID64706055682598"> <LONG-NAME>TABLE NAME</LONG-NAME> </TABLE-CAPTION> <TGROUP COLS="4"> <COLSPEC COLNUM="1" COLNAME="col1" COLWIDTH="1.00*"/> <COLSPEC COLNUM="2" COLNAME="col2" COLWIDTH="1.00*"/> <COLSPEC COLNUM="3" COLNAME="col3" COLWIDTH="1.00*"/> <COLSPEC COLNUM="4" COLNAME="col4" COLWIDTH="1.00*"/> <TBODY> <ROW> <ENTRY COLNAME="col1">A</ENTRY> <ENTRY COLNAME="col2">B</ENTRY> <ENTRY COLNAME="col3">C</ENTRY> <ENTRY COLNAME="col4">D</ENTRY> </ROW> <ROW> <ENTRY COLNAME="col1">E</ENTRY> <ENTRY COLNAME="col2">F</ENTRY> <ENTRY COLNAME="col3">G</ENTRY> <ENTRY COLNAME="col4">H</ENTRY> </ROW> </TBODY> </TGROUP> </TABLE>
So in the end i got this:
This read about parameters to XML Simple like VauleAttr and KeyAttr but it seems to have no effect. As far as i have understood i can define with ValueAttr what should be printed as Value and not as Attribute.. Maybe i have misunderstood this API? The same idea i have form KeyAttr so i can define what hash-keys are in the end Attributes and no values..<TABLE> <TABLE-CAPTION ID="ID64706055682598" LONG-NAME="TABLE NAME" /> <TGROUP COLS="4"> <COLSPEC COLNAME="col1" COLNUM="1" COLWIDTH="1.00*" /> <COLSPEC COLNAME="col2" COLNUM="2" COLWIDTH="1.00*" /> <COLSPEC COLNAME="col3" COLNUM="3" COLWIDTH="1.00*" /> <COLSPEC COLNAME="col4" COLNUM="4" COLWIDTH="1.00*" /> <TBODY> <ROW> <ENTRY COLNAME="col1">A</ENTRY> <ENTRY COLNAME="col2">B</ENTRY> <ENTRY COLNAME="col3">C</ENTRY> <ENTRY COLNAME="col4">D</ENTRY> </ROW> <ROW> <ENTRY COLNAME="col1">E</ENTRY> <ENTRY COLNAME="col2">F</ENTRY> <ENTRY COLNAME="col3">G</ENTRY> <ENTRY COLNAME="col4">H</ENTRY> </ROW> </TBODY> </TGROUP> </TABLE>
I am stuck in the middle, any help is highly welcome!
Here my prototype where i read in the an xml-file with the content of the first XML-structure i have put here. By this i can check if (at the end) i will get the same XML-structure back when looking at $xml:
use XML::Simple; use strict; my $xmlParser = new XML::Simple( RootName => 'TABLE', KeepRoot=>1, ValueAttr=>{ 'TABLE-CAPTION' => 'LONG-NAME', }); my $data = $xmlParser->XMLin("testtable.xml"); my $xml = $xmlParser->XMLout($data); print "stop";
Any help is highly welcome!
Regards!
Tobias
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: XML::Simple how do i keep the same xml format (Values and Attributs)?
by hdb (Monsignor) on Jun 14, 2013 at 11:01 UTC | |
by jakeease (Friar) on Jun 15, 2013 at 08:45 UTC | |
Re: XML::Simple how do i keep the same xml format (Values and Attributs)? (XML::Rules)
by Anonymous Monk on Jun 14, 2013 at 10:08 UTC | |
Re: XML::Simple how do i keep the same xml format (Values and Attributs)?
by tobias_hofer (Friar) on Jun 14, 2013 at 10:45 UTC | |
by tobyink (Canon) on Jun 14, 2013 at 11:17 UTC | |
by tobias_hofer (Friar) on Jun 14, 2013 at 12:08 UTC | |
by Jenda (Abbot) on Jun 14, 2013 at 13:52 UTC |
Back to
Seekers of Perl Wisdom