I have a network that I monitor for performance. Each of the many nodes creates a performance monitoring XML file every 15 minutes. I would like to be able to extract specific data from the XML files, perform calculations on those bits of data, then create a gnuplot from that. I have what I need for the chart (gnuplot), but I cannot figure out how to get the data programmatically from the XML files.

You'll notice that the XML is in a format similar to this:

counter1 counter2 counter3 counter4 value1 value2 value3 value4

I am (obviously) new to this and was hoping for some pointers to get me going. I've read XML files with PERL in the past and have had a lot of luck with XML::Simple, but I can't get this working with my current files.

Specifically, I'd like to be able to extract Counter1/Value1 & Counter3/Value3, etc.

Thanks in advance!

Sample XML below. Let's say I'm looking for <mt>pmLicUlPrbCapDistr</mt> which can be found in <r>90083,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0</r> below.

<?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="MeasDataCollection.xsl"?> <!DOCTYPE mdc SYSTEM "MeasDataCollection.dtd"> <mdc xmlns:HTML="http://www.w3.org/TR/REC-xml"> <mfh> <ffv>32.401 V6.2</ffv> <sn>SubNetwork=ONRM_ROOT_MO_R,SubNetwork=SAMPLE,MeContext=LTE0 +001_SITE</sn> <st></st> <vn></vn> <cbt>20140401204500Z</cbt> </mfh> <md> <neid> <neun>LTE0001_SITE</neun> <nedn>SubNetwork=ONRM_ROOT_MO_R,SubNetwork=SAMPLE,MeContex +t=LTE0001_SITE</nedn> <nesw>CXP102051/18_R21BN</nesw> </neid> <mi> <mts>20140401210000Z</mts> <gp>900</gp> <mt>pmPdcpPktDiscDlEth</mt> <mv> <moid>ManagedElement=1,ENodeBFunction=1</moid> <r>0</r> </mv> </mi> </md> <md> <neid> <neun>LTE0001_SITE</neun> <nedn>SubNetwork=ONRM_ROOT_MO_R,SubNetwork=SAMPLE,MeContex +t=LTE0001_SITE</nedn> <nesw>CXP102051/18_R21BN</nesw> </neid> <mi> <mts>20140401210000Z</mts> <gp>900</gp> <mt>pmLicDlCapActual</mt> <mt>pmLicUlCapActual</mt> <mt>pmLicDlPrbCapActual</mt> <mt>pmLicUlPrbCapActual</mt> <mt>pmPdcpPktDiscDlEth</mt> <mt>pmPdcpPktDiscUlEthPacing</mt> <mt>pmLicDlCapDistr</mt> <mt>pmLicUlCapDistr</mt> <mt>pmLicDlPrbCapDistr</mt> <mt>pmLicUlPrbCapDistr</mt> <mv> <moid>ManagedElement=1,Equipment=1,Subrack=1,Slot=1,Pl +ugInUnit=1,DeviceGroup=dul,BbProcessingResource=1</moid> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>81893,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0</r> <r>90083,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0</r> <r>81893,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0</r> <r>90083,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0</r> </mv> </mi> </md> <mff><ts>20140401210000Z</ts></mff> </mdc>

In reply to Extract Data from XML (unique xml format?) by clapeters

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.