There are freely available, tiny, pure Perl XML parsers available. These are small enough you could copy paste them into your Perl program.

The tiniest one (less than 50 lines) returns a list of parsed elements. From the list, you can find the first occurrence of RemoteHost, then find the hostname, synopsis and other elements you want and extract their values. Then find the /RemoteHost element, then find the next RemoteHost element, find and extract the subelement, finally, repeat until end of file reached.

This one is at http://www.cs.sfu.ca/~cameron/REX.html#AppA in appendix A.

The other is actually the module XML::Parser::Lite and is based on the above parser. It's a little easier to use than the "bare" parser. The module is small enough you could copy/paste it into your Perl program. It does not have to be its own package, or you can do package main; after the end of XML::Parser::Lite

HOWEVER, you can not use regular expressions - or even split - in your call back functions when using XML::Parser::Lite because the callbacks are being called by Perls regex engine. However, you should not need to use regular expressions or split as the element names given to the callbacks can be directly compared (using eq) to scalar values and the element values are cleanly extracted.


In reply to Re: No tools? Use Perl?! by RonW
in thread No tools? Use Perl?! by Boyd.Ako

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.