XPath query
-
Hi all, I just need some help with an XPath query. I have a document like ... ... ... and I would like to get (from a pointer to my_items) all elements with a "name" attribute where the attribute is not empty. That would be item 1 and 2 above. I've tried with a query like _bstr_t bstrQuery = "item[(string-length(@name) > 0)]"; - but it doesn't work. Got any hints ? I really need a useful resource for practical knowledge about XPath. All I've got is Essential XML Quick Reference by Aaron Skonnard and Martin Gudgin. It's definately good - but despite its humble size rather heavy ;) I suppose a reference is supposed to be that though. Well, thanks in advance for any help or pointers. /Jan
-
Hi all, I just need some help with an XPath query. I have a document like ... ... ... and I would like to get (from a pointer to my_items) all elements with a "name" attribute where the attribute is not empty. That would be item 1 and 2 above. I've tried with a query like _bstr_t bstrQuery = "item[(string-length(@name) > 0)]"; - but it doesn't work. Got any hints ? I really need a useful resource for practical knowledge about XPath. All I've got is Essential XML Quick Reference by Aaron Skonnard and Martin Gudgin. It's definately good - but despite its humble size rather heavy ;) I suppose a reference is supposed to be that though. Well, thanks in advance for any help or pointers. /Jan
make sure your using something newer than msxml2, which does not support string-length. some resources: http://www.w3.org/TR/xpath http://www.vbxml.com/xsl/XPathRef.asp http://www.zvon.org:9001/saxon/cgi-bin/XLab/XML/extras.html?stylesheetFile=XSLT/xpath.xslt&lang=eng
-
make sure your using something newer than msxml2, which does not support string-length. some resources: http://www.w3.org/TR/xpath http://www.vbxml.com/xsl/XPathRef.asp http://www.zvon.org:9001/saxon/cgi-bin/XLab/XML/extras.html?stylesheetFile=XSLT/xpath.xslt&lang=eng
Thanks for the links - actually useful ;) I solved the problem yesterday by using @name != "" - but thanks anyway. /Jan
-
Hi all, I just need some help with an XPath query. I have a document like ... ... ... and I would like to get (from a pointer to my_items) all elements with a "name" attribute where the attribute is not empty. That would be item 1 and 2 above. I've tried with a query like _bstr_t bstrQuery = "item[(string-length(@name) > 0)]"; - but it doesn't work. Got any hints ? I really need a useful resource for practical knowledge about XPath. All I've got is Essential XML Quick Reference by Aaron Skonnard and Martin Gudgin. It's definately good - but despite its humble size rather heavy ;) I suppose a reference is supposed to be that though. Well, thanks in advance for any help or pointers. /Jan
correct way is
item[not(@name)]
"When the only tool you have is a hammer, a sore thumb you will have."