Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re^4: Is there any XML reader like this?

by BrowserUk (Pope)
on Jan 14, 2012 at 00:24 UTC ( #947853=note: print w/replies, xml ) Need Help??

in reply to Re^3: Is there any XML reader like this?
in thread Is there any XML reader like this?

And here's another reason. Once you've fixed your first error, your code prints nothing at all

my $root = XML::LibXML->load_xml( IO => \*DATA )->documentElement; for my $station ($root->findnodes('servers/*')) { say $station->name; for my $ip ( $station->findnodes('ip') ) { say " ".$ip->textContent; } }

No values. No errors. Nothing! Nada! Zitch! Zip! Not a jot!

Why? You'll have to go back and wade through those 32 pages again to work that out!

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

The start of some sanity?

Replies are listed 'Best First'.
Re^5: Is there any XML reader like this?
by ikegami (Pope) on Jan 14, 2012 at 06:36 UTC
    The documentation for the Parser is all in one page, not 32. The second error was an XPath error. Fixed. At least they were documented an easy to find. Note that I had as many mistakes in the XML::Simple version first.

      Documentation for the parser? Which one is that if I may ask? perldoc XML::LibXML prints something that definitely doesn't fit a single page and ... doesn't tell me anything of use. perldoc XML::LibXML::Parser doesn't fit on a single page either and ... OK, it explains how I turn the XML into a maze of interconnected objects. It says that I can use it to parse not only XML, but also HTML and SGML and god knows what else. It doesn't say anything about what the heck am I supposed to do with the maze of objects. It doesn't even care to tell me what's the $doc all those tons of methods return. Nada, nil, nothing. So back to the XML::LibXML docs ... OK, XML::LibXML::Document looks promising, perldoc XML::LibXML::Document. 43 methods (if I did not loose count somewhere in the muddle). Maybe more because maybe the object inherits methods from some other but ... no info about that in the docs either ... basically looking at the docs seems the only way to get at the data is to call the ->documentElement() and then ... OK, maybe what I get is a XML::LibXML::Element or something. Or maybe I could call ->getElementsByTagName() but ... "Implements the DOM Level 2 function" now what the fsck is that? You call that documentation?

      And XPath? Where's that even just mentioned in the docs? Oh, I see. The start of the description:

      This module is an interface to the gnome libxml2 DOM and SAX parser and the DOM tree. It also provides an XML::XPath-like findnodes() interface, providing access to the XPath API in libxml2.
      So what docs am I supposed to find and read? If anything I just installed a Perl module XML::LibXML, not some, what was it, gnomio&juliet libxml2. And a XML::XPath-like? How much alike? Where do I find the docs? So am I supposed to use XML::XPath instead or what?

      No guys, really, I did look at XML::LibXML a few years ago and tried to learn how to use it, but hey ... I had some work to do, I did not have time to search docs hardly mentioned in these and then other docs and then god only knows what else. Some time later I tried to see what would it take to change XML::Rules to use the universally hailed SAX instead of the good old XML::Parser::Expat, but ... maybe the docs make sense to someone, they did not make any to me.

      For someone who had to learn all that XAnythingYouCanThinkOf and DOM nonsense for other languages, the docs of XML::LibXML may contain all info they need. Or at least enough to get them started. For others it's one of the least helpfull documentation found for a Perl module.

      Enoch was right!
      Enjoy the last years of Rome.

        Hi, you might like XML::LibXML - WHAR HASH TREES WHAR?!

        FWIW, when I want to learn a new package, I skip the SYNOPSIS and go straight for the test suite -- its code that actually runs :)

        perldoc XML::LibXML prints something that definitely doesn't fit a single page and

        uh, the Parser is documented in XML::LibXML::Parser.

        And XPath? Where's that even just mentioned in the docs?

        Are you asking where it's documented that XML::LibXML::Node::findnodes takes an XPath, or are you asking where XPaths are documented in XML::LibXML.

        If the former, XML::LibXML::Node.

        If the latter, your argument is ridiculous. XML::LibXML is no more the place to document XPaths than XML::Simple is the place to document references.

Re^5: Is there any XML reader like this?
by ashok.g (Beadle) on Jan 14, 2012 at 10:10 UTC
    Nothing is printing!


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://947853]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (6)
As of 2018-04-22 23:18 GMT
Find Nodes?
    Voting Booth?