Re: [xml] xmllint - Browsing in file with default namespace

That does it. Thank you :)


On Sun, Jan 10, 2010 at 9:42 PM, Emmanuel Rodriguez <emmanuel rodriguez gmail com> wrote:

On Sun, Jan 10, 2010 at 9:24 PM, Thomas Larsen Wessel <mrvelle gmail com> wrote:
As far as I have been told, xmllint should offer a command line tool to work with xml, and than includes xhtml.

But it seems that I can not browse around in the xmllint shell, when the xml file has a default namespace. E.g. as in this file, minimum.xml:

<?xml version="1.0" encoding="UTF-8"?>
  "-//W3C//DTD XHTML 1.0 Strict//EN"
<html xmlns="" xml:lang="en" lang="en">
    <head> <title> minimum </title> </head>
        <p> Time for text </p>

Now trying to use the xmllint shell from command line:
mik borneo:~$ xmllint --shell foo.xml
/ > cd html
html is a 0 Node Set
/ >

If I remove the line "xmlns="", then I can browse around.

How can I browse around a document with a default namespace?
Register the name space in the shell:

/ > setns x=
/ > cd x:html

If you want to avoid the registration of namespaces you can also use xpath xpressions:
/ > cd *
html > cd *[1]
head >

But you will be better with namespaces :)

Emmanuel Rodriguez

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]