HighTechTalks DotNet Forums  

XPath to node with empty value

Dotnet XML microsoft.public.dotnet.xml


Discuss XPath to node with empty value in the Dotnet XML forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
esebastian@esolutionsgroup.ca
 
Posts: n/a

Default XPath to node with empty value - 07-11-2007 , 04:57 PM






Hi all,
Basically i want to do get the specific node that is empty but when i
try the following i get a null node even though I know there is a node
whose AN value is null. What am i doing wrong?


"/my:MF/my:SVY/my:INSP/my:INA/my:IA/my:AN[text()='']";

Thanks,
Erin


Reply With Quote
  #2  
Old   
Bjoern Hoehrmann
 
Posts: n/a

Default Re: XPath to node with empty value - 07-11-2007 , 11:20 PM






* esebastian (AT) esolutionsgroup (DOT) ca wrote in microsoft.public.dotnet.xml:
Quote:
Basically i want to do get the specific node that is empty but when i
try the following i get a null node even though I know there is a node
whose AN value is null. What am i doing wrong?

"/my:MF/my:SVY/my:INSP/my:INA/my:IA/my:AN[text()='']";
In the XPath data model, there exists no text node whose value is the
empty string, <foo></foo> is represented as having no children at all.
So text() evaluates to an empty node set, <http://www.w3.org/TR/xpath>:

If one object to be compared is a node-set and the other is a string,
then the comparison will be true if and only if there is a node in the
node-set such that the result of performing the comparison on the
string-value of the node and the other string is true.

which does not contain a corresponding node. Use [not(text())] instead.
--
Björn Höhrmann · mailto:bjoern (AT) hoehrmann (DOT) de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/


Reply With Quote
  #3  
Old   
Bjoern Hoehrmann
 
Posts: n/a

Default Re: XPath to node with empty value - 07-11-2007 , 11:20 PM



* esebastian (AT) esolutionsgroup (DOT) ca wrote in microsoft.public.dotnet.xml:
Quote:
Basically i want to do get the specific node that is empty but when i
try the following i get a null node even though I know there is a node
whose AN value is null. What am i doing wrong?

"/my:MF/my:SVY/my:INSP/my:INA/my:IA/my:AN[text()='']";
In the XPath data model, there exists no text node whose value is the
empty string, <foo></foo> is represented as having no children at all.
So text() evaluates to an empty node set, <http://www.w3.org/TR/xpath>:

If one object to be compared is a node-set and the other is a string,
then the comparison will be true if and only if there is a node in the
node-set such that the result of performing the comparison on the
string-value of the node and the other string is true.

which does not contain a corresponding node. Use [not(text())] instead.
--
Björn Höhrmann · mailto:bjoern (AT) hoehrmann (DOT) de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/


Reply With Quote
  #4  
Old   
esebastian@esolutionsgroup.ca
 
Posts: n/a

Default Re: XPath to node with empty value - 07-12-2007 , 03:22 PM



Thank you so much,
That worked perfectly!
Erin


Reply With Quote
  #5  
Old   
esebastian@esolutionsgroup.ca
 
Posts: n/a

Default Re: XPath to node with empty value - 07-12-2007 , 03:22 PM



Thank you so much,
That worked perfectly!
Erin


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.