Solved

have "absolute" xpath, want to get the node back

Posted on 2004-09-23
7
283 Views
Last Modified: 2010-04-15
I have loaded and xsd file into a treeview control, then saved "full path" to the node. When I reload this .xsd file later, I just want to select this particular node programatically. I have this line:

      nd = mSchemaXMLDoc.SelectSingleNode( "self::/" + mCurrentSchema.TagXPath.Replace( "\\", "/"));

wherein the string argument to SelectSingleNode evaluates to :

"self::/xs:schema/xs:element/xs:complexType/xs:attribute/xs:annotation"



giving the error: "The expression passed to this method should result in a NodeSet"

What am I doing wrong?
0
Comment
Question by:sperodev
  • 2
  • 2
7 Comments
 
LVL 8

Expert Comment

by:Razzie_
Comment Utility
Well what it basically means is that string argument does not point to a node. A common problem of this is that you have a trailing '/' at the end of your xpath. It's hard to judge what's wrong without the xsd file.

I'd recommend you make absolutely sure the string argument evaluates to "self::/xs:schema/xs:element/xs:complexType/xs:attribute/xs:annotation" and if it matches the xpath in your document.
0
 

Author Comment

by:sperodev
Comment Utility
Sorry, this wasn't a great deal of help.  The crux of the matter had more to do with those xs:'s being part of a schema. Thanks, anyway, though.
0
 

Author Comment

by:sperodev
Comment Utility
Sorry, I meant part of a namespace.
0
 
LVL 8

Accepted Solution

by:
Razzie_ earned 225 total points
Comment Utility
Hmm ok well it's hard without your xml and namespace file because I can't see the structure, but shouldn't it be more like nd = mSchemaXMLDoc.SelectSingleNode( "//self:" + mCurrentSchema.TagXPath.Replace( "\\", "/")); ?
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now