Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

hash to xml and back

Status
Not open for further replies.

arcnon

Programmer
Aug 12, 2003
242
US
I have been fiddling with this trying to get XML::Simple to produce the correct xml file. It makes a file it just doesn't read it back in correctly.
Code:
my %t_type = (
...
	'b' => {
		a => {low => 1000, high => 3000, percent => 25},
		b => {low => 200,high => 2000, percent => 30},
		c => {low => 1000,high => 6000, percent => 40},
		d => {low => 300,high => 1800, percent => 35},
		e => {low => 10, high => 40, percent => 60},
		f => {low => 2, high => 12, percent => 50},
		g => [
			{select => 'new',low => 1,high => 1,percent => 10},
			{select => 'expert',low => 1,high => 1,percent => 10},
		],
	},
...
);
note: the g hash of arrays has at least 1 element but can be more.

In the current xml file output. It creates mutiple g's with 1 entry per g array item. Which when read back in it produces a differant struture. This is the options I am using to produce the file.
Code:
print L $xsimple->XMLout(\%t_type,
                       noattr => 1,
                       xmldecl => '<?xml version="1.0"?>',
                       );
I tried the GroupTags => { '' => 'g' }but I dont know how have it recognize the parent of the g group.

any suggestions, solutions.

BTW the reason I dont just change the hash structure is I already have the application fully written and modifing 6000 lines of code will suck. I hope it will be the last ditch solution that I wont need.
 
Is this correct?
Code:
print L $xsimple->XMLout(\%t_type, noattr => 1, xmldecl => '<?xml version="1.0"?>', GroupTags => { 'g' => 'select' } );
Cheers, Neil
 
nope.

this is the output

<g>
<select>
<high>3</high>
<low>3</low>
<percent>30</percent>
<select>any</select>
</select>
</g>
 
anything is worth a shot thanks neil
 
this is it

GroupTags => { 'g' => 'element' }
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top