Hi, 

I have a XML file (test.xml) as follows: 

<?xml version="1.0" encoding="UTF-8"?>
<xml>
  <table>
    <rec id="1">
      <para type="error" position="1"/>
      <para type="error" position="2"/>
      <para type="error" position="3"/>
    </rec>
    <rec id="2">
      <para type="warning" position="1"/>
      <para type="warning" position="2"/>
      <para type="warning" position="3"/>
    </rec>
    <rec id="3">
      <para type="info" position="1"/>
      <para type="info" position="2"/>
      <para type="info" position="3"/>
    </rec>
  </table>
</xml>
 
Appling command line "xmllint.exe --xpath 
/descendant::node()/rec/child::node()[1] test.xml", the output are several 
empty lines.
 
If I change the XPath expression to 
/descendant::node()/rec/child::*[1] or /descendant::node()/rec/para[1], the 
output would be: 

<para type="error" position="1"/><para type="warning" position="1"/><para 
type="info" position="1"/> 

According to the XPath spec (V2.0 section 3.2.3 Unabbreviated 
Syntax) : child::node() selects all the children of the context node. Note 
that no attribute nodes are returned, because attributes are not 
children. 

Shouldn’t it have the same output as 
/descendant::node()/rec/child::*[1] and /descendant::node()/rec/para[1]? 

As for the tools that I used:   (Win32 version from 
http://www.zlatkovic.com/libxml.en.html)
 
libxml2-2.7.8.win32 (depends on iconv-1.9.2.win32 and zlib-1.2.5.win32). A 
xmllint.exe tool has been included in the "bin" directory.
 
Thanks for any comments on this...
 
Ming 
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xml@gnome.org
http://mail.gnome.org/mailman/listinfo/xml

Reply via email to