in reply to Re: How to parse xml with namespase vale in XMl:LibXML? ( XPath error : Undefined namespace prefix )
in thread How to parse xml with namespase value in XMl:LibXML?
<?xml version="1.0" encoding="UTF-8"?> <book xmlns:book="http://generated.ns/book"> <book:chapter id="bk444444ch1" type="CHAPTER"> <book:locator xmlns:xlink="http://www.w3.org/1999/xlink" xlink:hre +f="/book/isbn/979-0-4444-1000-17/book-part/chapter/bk444444ch1?releas +eStatus=RELEASED" xlink:title="Photonic crystal light-emitting source +s" xlink:type="locator"></book:locator> <book:locator xmlns:xlink="http://www.w3.org/1999/xlink" xlink:hre +f="/book/isbn/979-0-4444-1000-17/book-part/chapter/bk444444ch1?releas +eStatus=RELEASED&format=pdf" xlink:title="Photonic crystal light- +emitting sources" xlink:type="locator"></book:locator> <book:locator xmlns:xlink="http://www.w3.org/1999/xlink" xlink:hre +f="/book/isbn/979-0-4444-1000-17/book-part/chapter/bk444444ch1?releas +eStatus=RELEASED&format=epub" xlink:title="Photonic crystal light +-emitting sources" xlink:type="locator"></book:locator> </book:chapter> </book>
And then setns/query using xmllint --shell
$ xmllint.exe --shell ravi06-03.xml / > / > whereis //@xlink:href XPath error : Undefined namespace prefix xmlXPathEval: evaluation failed //@xlink:href: no such node / > / > setns xlink=http://www.w3.org/1999/xlink / > / > whereis //@xlink:href /book/book:chapter/book:locator[1]/@xlink:href /book/book:chapter/book:locator[2]/@xlink:href /book/book:chapter/book:locator[3]/@xlink:href / > / > cat //@xlink:href ------- xlink:href="/book/isbn/979-0-4444-1000-17/book-part/chapter/bk444444c +h1?releaseStatus=RELEASED" ------- xlink:href="/book/isbn/979-0-4444-1000-17/book-part/chapter/bk444444c +h1?releaseStatus=RELEASED&format=pdf" ------- xlink:href="/book/isbn/979-0-4444-1000-17/book-part/chapter/bk444444c +h1?releaseStatus=RELEASED&format=epub" / > / > / > cat (//@xlink:href/..)[1] ------- <book:locator xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="/ +book/isbn/979-0-4444-1000-17/book-part/chapter/bk4 44444ch1?releaseStatus=RELEASED" xlink:title="Photonic crystal light-e +mitting sources" xlink:type="locator"/> / > / > / > bye $
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: How to parse xml with namespase vale in XMl:LibXML? (xmllint --shell setns / xpathtester)
by ravi06 (Novice) on Jul 08, 2013 at 12:10 UTC | |
by choroba (Cardinal) on Jul 08, 2013 at 12:19 UTC | |
by ravi06 (Novice) on Jul 08, 2013 at 19:11 UTC | |
by choroba (Cardinal) on Jul 08, 2013 at 20:30 UTC | |
by Anonymous Monk on Jul 09, 2013 at 02:42 UTC | |
| |
by Anonymous Monk on Jul 08, 2013 at 13:38 UTC |