Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - Accessing attributes via XPath [Thread Next] Re: Accessing attributes via XPathTo: 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 | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
