troubleshooting Question

Problem in generating the XML from a hash in Perl

Avatar of Tolgar
Tolgar asked on
Perl
5 Comments1 Solution367 ViewsLast Modified:
Hi,
I have the following hash in Perl:

 
DB<3> x %report_hash_XML
0  'File'
1  HASH(0x2124580)
   'FileReport' => HASH(0x3454ce0)
      'Check' => HASH(0x3454b90)
         'AutoFix' => 'no'
         'CheckName' => 'somecheckname'
         'CheckStatus' => 'PASSED'
         'Location' => HASH(0x3524ca0)
            'Length' => 'n/a'
            'LineNumber' => undef
            'Start' => 'n/a'
         'Message' => 0
   'Name' => 'some name'
2  'Date'
3  'Monday, July 08, 2013  14:35:25'

I use this code to generate the XML file:

XMLout($report_hash_XML, NoAttr => 1, RootName => 'Report', OutputFile => "$reportLocation/$fileName");

And it generates this XML file:

<Report>
  <Date>Monday, July 08, 2013  14:32:11</Date>
  <File>
    <FileReport>
      <name>Check</name>
      <AutoFix>no</AutoFix>
      <CheckName>somecheckname</CheckName>
      <CheckStatus>PASSED</CheckStatus>
      <Location>
        <Length>n/a</Length>
        <LineNumber></LineNumber>
        <Start>n/a</Start>
      </Location>
      <Message>0</Message>
    </FileReport>
    <Name>some name</Name>
  </File>
</Report>

However, I expect to see this:

<Report>
  <Date>Monday, July 08, 2013  14:32:11</Date>
  <File>
    <FileReport>
      <Check>
         <AutoFix>no</AutoFix>
         <CheckName>somecheckname</CheckName>
         <CheckStatus>PASSED</CheckStatus>
         <Location>
           <Length>n/a</Length>
           <LineNumber></LineNumber>
           <Start>n/a</Start>
         </Location>
         <Message>0</Message>
      </Check>
    </FileReport>
    <Name>some name</Name>
  </File>
</Report>

Why can't I generate this <CHECK> tag and why does <name> tag show up even though I don't have it in the hash?
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros