in reply to Re^4: XML::Simple--dealing with a variable element
in thread XML::Simple--dealing with a variable element
use XML::Simple; $data = XMLin( \*DATA, KeepRoot => 1 ); @attrs = map { keys %{ $_->{attributes}{attribute} } } values %{ $data->{dataschemas}{dataschema} }; print "@attrs"; __DATA__ <dataschemas> <dataschema name="varyingName1"> <attributes> <attribute> <one>1</one> <two>2</two> </attribute> </attributes> </dataschema> <dataschema name="varyingName2"> <attributes> <attribute> <three>3</three> <four>4</four> </attribute> </attributes> </dataschema> </dataschemas>
Prints: one two three four
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: XML::Simple--dealing with a variable element
by bw (Novice) on Jul 26, 2006 at 23:33 UTC |