Hello Monks.
I am using XML::Simple for xml processing.
I read in following from a file:
<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>
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.
So in the end i got this:
<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>
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..
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
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.