Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

How to parse xml with namespase value in XMl:LibXML?

by ravi06 (Novice)
on Jul 08, 2013 at 08:53 UTC ( #1043053=perlquestion: print w/replies, xml ) Need Help??
ravi06 has asked for the wisdom of the Perl Monks concerning the following question:

<book> <book:chapter id="bk444444ch1" type="CHAPTER"> <book:locator xlink:href="/book/isbn/979-0-4444-1000-17/book-part/chap +ter/bk444444ch1?releaseStatus=RELEASED" xlink:title="Photonic crystal + light-emitting sources" xlink:type="locator" xmlns:xlink="http://www"/> <book:locator xlink:href="/book/isbn/979-0-4444-1000-17/book-part/chap +ter/bk444444ch1?releaseStatus=RELEASED&amp;format=pdf" xlink:title="P +hotonic crystal light-emitting sources" xlink:type="locator" xmlns:xl +ink=""/> <book:locator xlink:href="/book/isbn/979-0-4444-1000-17/book-part/chap +ter/bk444444ch1?releaseStatus=RELEASED&amp;format=epub" xlink:title=" +Photonic crystal light-emitting sources" xlink:type="locator" xmlns:x +link=""/> </book>
How can i get "xlink:href" of first instance of book:locator?

Replies are listed 'Best First'.
Re: How to parse xml with namespase vale in XMl:LibXML? ( XPath error : Undefined namespace prefix )
by Anonymous Monk on Jul 08, 2013 at 09:21 UTC
        But when I am trying to access the nodes as below I don't get any value.
        print $chapter_node->findvalue('./book:locator/@xlink:href') . "\n";
        Could you please elaborate a bit or point out where I am committing mistake?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1043053]
Approved by Corion
[LanX]: ;-P
[LanX]: What I learned now is to hide my friends list at FB (not that I have many ...)
[Your Mother]: Careful. They're listening!
[LanX]: I mean hiding my friends FROM my friends
[Your Mother]: Yeah. I don't know what they expect. If a stranger can see the post or list or whatever, so can a harvesting program.
[Your Mother]: HA.
[NodeReaper]: he's already hiding from me :(
[Corion]: Your Mother: Even I don't remember what "related and neat" I could have that would fit to 1211240 :) Maybe "pjax", which turns a static site into a Javascript-partial -reloading site? That's purely Javascript though
[LanX]: true I might get visa problems when they hear about my love for massacres ...
[Your Mother]: Corion, it was something similar to Cometd/Websockets.

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (14)
As of 2018-03-19 13:33 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (240 votes). Check out past polls.