Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: Stepping up from XML::Simple to XML::LibXML

by chovy (Initiate)
on Sep 17, 2008 at 22:05 UTC ( #712128=note: print w/replies, xml ) Need Help??

in reply to Stepping up from XML::Simple to XML::LibXML

The example is an xml fragment, can you show one using a real xml file? One with a default namespace declared... It appears if you have: <library xmlns=""> </library> Then what would the xpath queries look like?
  • Comment on Re: Stepping up from XML::Simple to XML::LibXML

Replies are listed 'Best First'.
Re^2: Stepping up from XML::Simple to XML::LibXML
by Anonymous Monk on Oct 22, 2008 at 22:00 UTC
    This is the exact problem I am trying to solve now (namespace defined at library).
    I added:
    my $xc = XML::LibXML::XPathContext->new($doc);<br/> $xc->registerNs('ns', 'xmlapi_1.0');
    and changed the foreach to:
    foreach my $book ($xc->findnodes('//ns:book')) {

    But no matter what I try, I can't get book's attributes. I know I'm getting the info (print $book->to_literal, "\n";) but how do I access the info individually?

      That problem was addressed in a separate thread. I meant to provide a link from here but then I forgot.

      Aristotle provided a comprehensive answer in this node.

        Thanks grantm. Please see me reply to that post. I'm still missing... something!
      It would be really nice if the code was explained in English, line by line. For a newbie Perl writer figuring out what the different items mean is almost impossible. A guide that explains items would be most helpful. Example what the heck is findnodes what other keywords can be used and how

        XML::LibXML has a fairly extensive documentation. For example findnodes is documented in XML::LibXML::Node, along with many other methods that can be used on any node, since it's the base class for all nodes. The general idea of how the XML document is represented is explained in this tutorial:

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://712128]
[Lady_Aleena]: Corion, so do you think the gods would be open to taking over Cookies should I disappear for too long a time?
[Corion]: Lady_Aleena: Yes, I think so, but maybe someone else might also take care of the cookies ;)
[Lady_Aleena]: I'll put it out there.

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (10)
As of 2017-04-26 08:34 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (471 votes). Check out past polls.