jmmistrot has asked for the wisdom of the Perl Monks concerning the following question:
I have no problem reading things in with XML-Simple<?xml version="1.0" encoding="utf-8"?> <AttributeDatabase> <attribclass toolonly="false" hidden="false" dbvault="true"> <editlist name="default"> <entry>*</entry> </editlist> <preferrededitlist>"default"</preferrededitlist> <attribdef name="mtl_param" synthetic="true" array="true"> <desc>IsSynthetic</desc> <type>Attrib.Types.Vector4</type> <bound>True</bound> <properties platform="common"> <mincount>2</mincount> <maxcount>2</maxcount> </properties> </attribdef> <attribdef name="mtl_Kdiff" toolonly="true"> <memberkeyvalue path="" key="push(bits)->::mtl_param:common +:0:w" /> <desc>controls --> mtl_param[0].w </desc> <type>EA.Reflection.Float</type> <bound>False</bound> <increment>0.001</increment> <properties platform="common"> <max>2.0</max> <min>0.0</min> <defaultreflectedobject>1.0</defaultreflectedobject> </properties> </attribdef> </attribclass> </AttributeDatabase>
I do stuff to it... and then go to write it out thus:my $fh; open( $fh , "<", $arg{file}) or die; my $xml = XML::Simple->new(KeepRoot=>1) ; my $xml_data = $xml->XMLin($fh);
but no matter which options I try with XML-Simple I can't reconstruct the same XML output as input. The closest I have come is:my $xml = XML::Simple->new(XMLDecl=>1,KeepRoot=>1) ; my $xml_data = $xml->XMLout($arg{data});
Notice how the embedded element attributes in the attribclass and attribdef tags drop out. and my quotes(") become " or drop out altogether... Does anyone know how to keep some attributes from dropping out of element tags and others let go? I am afraid I am gonna have to write out each element as I traverse the data structure so that can control the output of XMLout(). Anyone got any advice? Your humble DTD Destroyer, jmm<?xml version='1.0' standalone='yes'?> <AttributeDatabase> <attribclass> <attribdef> <name>mtl_Kdiff</name> <bound>False</bound> <desc>controls --> mtl_param[0].w </desc> <increment>0.001</increment> <memberkeyvalue> <key>push(bits)->::mtl_param:common:0:w</key> <path></path> </memberkeyvalue> <properties> <defaultreflectedobject>1.0</defaultreflectedobject> <max>2.0</max> <min>0.0</min> <platform>common</platform> </properties> <toolonly>true</toolonly> <type>EA.Reflection.Float</type> </attribdef> <attribdef> <name>mtl_param</name> <array>true</array> <bound>True</bound> <desc>IsSynthetic</desc> <properties> <maxcount>2</maxcount> <mincount>2</mincount> <platform>common</platform> </properties> <synthetic>true</synthetic> <type>Attrib.Types.Vector4</type> </attribdef> <dbvault>true</dbvault> <editlist> <name>default</name> <entry>*</entry> </editlist> <hidden>false</hidden> <preferrededitlist>"default"</preferrededitlist> <toolonly>false</toolonly> </attribclass> </AttributeDatabase>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: XML gurus unite!!
by Corion (Patriarch) on Mar 05, 2007 at 08:57 UTC | |
|
Re: XML gurus unite!!
by varian (Chaplain) on Mar 05, 2007 at 09:13 UTC | |
|
Re: XML gurus unite!!
by merlyn (Sage) on Mar 05, 2007 at 14:59 UTC | |
|
Re: XML gurus unite!!
by Herkum (Parson) on Mar 05, 2007 at 11:48 UTC | |
by vrk (Chaplain) on Mar 05, 2007 at 12:34 UTC | |
by Mark_UpLanguage (Sexton) on Mar 05, 2007 at 15:00 UTC | |
|
Re: XML gurus unite!!
by Moron (Curate) on Mar 05, 2007 at 12:29 UTC | |
by vrk (Chaplain) on Mar 05, 2007 at 12:36 UTC | |
by Moron (Curate) on Mar 05, 2007 at 12:46 UTC | |
|
Re: XML gurus unite!!
by dmitri (Priest) on Mar 05, 2007 at 20:55 UTC | |
|
Re: XML gurus unite!!
by gasho (Beadle) on Mar 06, 2007 at 18:01 UTC |