- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Need Help in Parsing XML through XML::Simple in Pe...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-25-2009 04:12 AM
тАО08-25-2009 04:12 AM
It's usrgent.I m very new to perl and xml.
I m trying to parse an xml file. Suppose the below, i cant give the original file becoz of some security reasons.
I need to get the data of Message, data, Action, Object for every Header but i m not able to find how to do that.Please tell me how to do proceeed with it.
Regards,
Mayank
Solved! Go to Solution.
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-25-2009 04:17 AM
тАО08-25-2009 04:17 AM
Re: Need Help in Parsing XML through XML::Simple in Perl.
Regards,
Mayank
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-25-2009 04:34 AM
тАО08-25-2009 04:34 AM
Re: Need Help in Parsing XML through XML::Simple in Perl.
the Data::Dumper output should have told you...
The attached sample code gets all header elements.
HTH,
Martin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-25-2009 06:03 AM
тАО08-25-2009 06:03 AM
Re: Need Help in Parsing XML through XML::Simple in Perl.
Please help me to solve it.
#!/usr/bin/perl
# use module
use XML::Simple;
use Data::Dumper;
# create object
$xml = new XML::Simple;
# read XML file
$data = $xml->XMLin("mgw.xml", ForceArray => 1, KeyAttr => []);
$PMTarget = $data->{OMeS}->{PMSetup}->{PMMOResult}-{PMTarget};
foreach my $header (@{$PMTarget})
{
print "CHECK 1";
print $PMTarget->{M617C0};
print $PMTarget->{M617C1};
print $PMTarget->{M617C2};
print $PMTarget->{M617C3};
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-26-2009 04:26 AM
тАО08-26-2009 04:26 AM
Solutionseveral things are wrong with your new code:
- the root element OMeS does not appear within the parsed object
- inside each hash there's an array of objects, so you have to insert "[0]" between accesses to hash references
- you got multiple PMMOResult elements, so your loop has to iterate over those (and not over the PMTarget elements
The attached code parses your XML file.
cu,
Martin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-26-2009 10:57 PM
тАО08-26-2009 10:57 PM
Re: Need Help in Parsing XML through XML::Simple in Perl.
in your case you run:
perldoc XML::Simple
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-27-2009 01:30 AM
тАО08-27-2009 01:30 AM
Re: Need Help in Parsing XML through XML::Simple in Perl.
Thanks Dirk for your suggestion.
Regards,
Mayank