go ahead... be a heretic | |
PerlMonks |
XMLout and Elements vs Attributesby atreyu (Sexton) |
on Feb 20, 2014 at 16:20 UTC ( [id://1075603]=perlquestion: print w/replies, xml ) | Need Help?? |
atreyu has asked for the wisdom of the Perl Monks concerning the following question:
Hi,
I'm having a problem formatting the output of XMLout, and my XML file must have a specific format. Here is my code that generates the data hash ref and then attempts to create an XML file: which yields: The output file, /tmp/testfile.xml, looks like this: So it properly makes id an attribute of the node, but it does the same for desc. I want desc to be a nested element of the node instead. So I need it to look like this:
Note that there will be keys other than desc that will potentially exist in the real hash, and those should be nested elements of the node, too. Can anyone spot my error(s) or see what XML option I am missing/misusing? Or do I have to reconstruct my hash ref (which is fine, too)? Btw, I make liberal use of the XML::Simple module elsewhere so I want to stay with that method. thx!
EDIT After reading this thread (particularly grantm's post at the end), I got my code to do what I wanted by defining the desc (and other) key values as anonymous arrays: Is this the right way to do this? I know, timtowtdi...
Back to
Seekers of Perl Wisdom
|
|