1

I need to parse an XML file using perl which I can load the file using the XML::Simple module but within the XML tree there is a tag that I can't see using the DataDumper module but I can see it's value instead.

    <testcase id="10">
        .
        .
        .
    </testcase>

Above is a Sample of the XML file with the testcase tag. It's the part that I have difficulty with. Using DataDumper to view the contents of the array I see something like this:

$VAR1 = {
          'testcases' => {
                         'file' => 'testcases.xml',
                         'testcase' => {
                                       '10' => {
                                                },

Since the XML is defined like why isn't it layed out in the VAR1 array with the id included? Instead of expecting testcases->testcase->id I get testcases->testcase->10. Which 10 is the id but what happened to the 'id' tag?

todd1215
  • 293
  • 3
  • 13

1 Answers1

4

That's because the default config includes

KeyAttr => [qw( name key id )]

Specifying

KeyAttr => []

will cause id to be no different than any other attribute.

ikegami
  • 367,544
  • 15
  • 269
  • 518
  • you right, it is an attribute. Boy I've not worked with XML in awhile. I think I need a refresher. Thanks for the pointer. – todd1215 Jan 05 '15 at 15:40