Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Accessing attributes via XPath

From: Peter Flynn <peter.nosp@-.--------.-->
To: NULL
Date: 7/1/2009 9:36:00 PM
Jeremy wrote:
> Hi folks,
> 
> Just cutting my teeth a bit with MSXML, and came across an issue that
> is confusing me.
> 
> Given the following XML fragment:
> 
> <parent>
>   <child>
>      <grandchild attrib1="test" />
>   </child>
> </parent>
> 
> I have an IXMLDOMNodePtr pointing to <child>, and I want to grab the
> value of attrib1 in <grandchild>.
> 
> I was expecting the XPath to feed to selectNodes() would be
> "grandchild@attrib1", but this causes MSXML to throw an exception
> (with no error info).
> 
> It turns out the correct XPath is "grandchild/@attrib1", and I was
> confused why, since I'm sure I've seen tutorials using the first
> format.

If the address is supposed to be an XPath expression, then the slash is 
mandatory. I haven't seen a different (ie non-XPath) syntax that just 
uses elementname@attribname but someone may well have invented one. If 
you can find the page you think you've seen, it may just be a typo.

//Peter


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent