Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / XML / July 2006

Tip: Looking for answers? Try searching our database.

XPathNavigator and name()

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
David Thielen - 09 Jul 2006 21:10 GMT
Hi;

Two questions. I have an XPathNavigator object where it's OuterXml property
is "<jan>231</jan>" and I am trying to write an xpath statement that will
return the "jan".

XPathNavigator nav = ...;

1) I can do nav.Evaluate("name(parent::*)"); and get "month". But if I do
nav.Evaluate("name(self::*)"); I get "" returned. Shouldn't I get "jan"?

2) This is for code that can be passed random xpath statements. For some it
seems I need to call nav.SelectSingleNode(xpath) and for some (the name()
example) nav.Evaluate(). Is there any way to have a single call that handles
any xpath?

Signature

thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Kevin Yu [MSFT] - 10 Jul 2006 04:12 GMT
Hi Dave,

Thanks for posting!

1. I tried to reproduce it, but with my code below, it is working fine. The
object returns "jan".

           XmlDocument doc = new XmlDocument();
           doc.LoadXml("<Month><jan>231</jan></Month>");
           XPathNavigator nav = doc.CreateNavigator();
           XPathNavigator n = nav.SelectSingleNode("//Month/jan");
           object o = n.Evaluate("name(self::*)");

Could you show me your code that can repro it? Thanks.

2. The SelectSingleNode method does different things from Evaluate method.
SelectSingleNode does an XPath query and returns another XPathNavigator, so
that you can move to another node with it.

However, Evaluate method evaluates an XPath expression and returns result.
It will be converted to an object.

Kevin Yu
Microsoft Online Community Support

============================================================================
==========================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
============================================================================
==========================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
David Thielen - 11 Jul 2006 02:40 GMT
I swear this wasn't working yesterday - but it work now. I must have types
something wrong without realizing it.

Signature

thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

> Hi Dave,
>
[quoted text clipped - 30 lines]
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
Kevin Yu [MSFT] - 11 Jul 2006 03:21 GMT
No problem, Dave. Anyway, it was nice to know that it's working for you.

If you have any questions, please feel free to post them in the community.

Kevin Yu
Microsoft Online Community Support

============================================================================
==========================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
============================================================================
==========================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.