Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - Xpath query to return "NULL" values? [Thread Next] Re: Xpath query to return "NULL" values?To: NULL Date: 6/5/2009 11:36:00 PM Mario Splivalo wrote: > Here is my XML document: > > <a> > <b>1</b> > <b>2</b> > <b></b> > <b>3</b> > </a> > > When I execute this XPath query against it: /a/b/text() > > I get only 1, 2 and 3: > > mario@mike:~$ echo "<a><b>1</b><b>2</b><b></b><b>3</b></a>" | xpath -e '/a/b/@id' > Found 3 nodes in stdin: > -- NODE -- > 1 > -- NODE -- > 2 > -- NODE -- > 3 > mario@mike:~$ > > Is there a way to extract that NULL-valued node? > > Mike xpath doesn't have a NULL value, and text nodes never have an empty string as value. the third b has no child node at all. It's actually rather rare to use text() in xpath, normally you'd just select the b nodes the xpath /a/b will select 4 b nodes with string values "1" "2" "" "3" In xpath 1 you can only have a node set so teh set of b nodes is the nearest you can get to this. In xpath2 you could return the sequence of string values directly as /a/b/string(.) David -- http://dpcarlisle.blogspot.com | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
