<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Getting Path from an XmlNode</title><link>http://blogs.msdn.com/b/kaevans/archive/2003/04/10/5318.aspx</link><description>Get the path of a particular System.Xml.XmlNode.</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: Getting Path from an XmlNode</title><link>http://blogs.msdn.com/b/kaevans/archive/2003/04/10/5318.aspx#179689</link><pubDate>Sun, 11 Jul 2004 04:06:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:179689</guid><dc:creator>Aaron</dc:creator><description>Wow, thanks for the quick response.  I'm running .NET 1.1.4322.573.  If I go in deeper to see what the exception is I get this: &amp;quot;System.Xml.XPath.XPathException&lt;br&gt;&lt;br&gt;The expression passed to this method should result in a NodeSet.&amp;quot;&lt;br&gt;&lt;br&gt;The XmlDocument only has 3 nodes in it for testing.&lt;br&gt;&lt;br&gt;The real part of the XPath that my app doesn't seem to like is, &amp;quot;ancestor-or-self::@*&amp;quot;.  The other half of the or works fine by itself.  I hope that's some more information for you.&lt;br&gt;&lt;br&gt;By the way, these msdn blogs are pretty sweet.  You guys always seem to have goo dtings to say.&lt;br&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=179689" width="1" height="1"&gt;</description></item><item><title>re: Getting Path from an XmlNode</title><link>http://blogs.msdn.com/b/kaevans/archive/2003/04/10/5318.aspx#179636</link><pubDate>Sun, 11 Jul 2004 02:09:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:179636</guid><dc:creator>Kirk Allen Evans</dc:creator><description>The statement selects along the ancestor node, including the current context node, looking for any elements or attributes.  &lt;br&gt;&lt;br&gt;Sounds like a pretty ambiguous description of the fault.  Have you tried debugging to any reasonable level of isolation?  There are several versions of the .NET framework available (beta, 1.0, 1.1, 2.0 beta), anything beta is unsupported.  If you are querying a huge document (huge being absolutely relative to your system's RAM and avialable memory w.r.t. other running applications), then you might be receiving some type of out of memory exception?&lt;br&gt;&lt;br&gt;Let's remember to be safe out there, people... don't try to run XPath statements over 5 Gig documents.  It just doesn't make sense.  You wouldn't pull back 50,000 rows from a database and filter on the client side, you would limit the amount of data you pull back from the database.  Amazingly, the same rules of conservative memory usage apply to XML:  there are 2 models, the DOM and the pull-based XmlReader parser... the DOM pulls everything into memory, the XmlReader reads one node at a time.&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=179636" width="1" height="1"&gt;</description></item><item><title>re: Getting Path from an XmlNode</title><link>http://blogs.msdn.com/b/kaevans/archive/2003/04/10/5318.aspx#178788</link><pubDate>Sat, 10 Jul 2004 00:24:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:178788</guid><dc:creator>Aaron</dc:creator><description>I'm curious what's going on with this XPath statement, &amp;quot;ancestor-or-self::* |&lt;br&gt;ancestor-or-self::@*&amp;quot;.  In my app it keeps on crashing giving me a system error.&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=178788" width="1" height="1"&gt;</description></item><item><title>re: Getting Path from an XmlNode</title><link>http://blogs.msdn.com/b/kaevans/archive/2003/04/10/5318.aspx#81981</link><pubDate>Mon, 01 Mar 2004 15:01:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:81981</guid><dc:creator>Kirk Allen Evans</dc:creator><description>You can use the DOM for this.  &lt;br&gt;&lt;br&gt;XmlDocument doc = new XmlDocument();&lt;br&gt;doc.Load(filePath);&lt;br&gt;XmlNode node = doc.SelectSingleNode(&amp;quot;/foo/bar[@baz='test']&amp;quot;);&lt;br&gt;if(null == bar)&lt;br&gt;{&lt;br&gt;   XmlNode barr = foo.AppendChild(doc.CreateElement(&amp;quot;bar&amp;quot;));&lt;br&gt;   XmlAttribute a = bar.Attributes.Add(doc.CreateAttribute(&amp;quot;baz&amp;quot;));   &lt;br&gt;   a.Value = &amp;quot;test&amp;quot;;&lt;br&gt;}&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=81981" width="1" height="1"&gt;</description></item><item><title>re: Getting Path from an XmlNode</title><link>http://blogs.msdn.com/b/kaevans/archive/2003/04/10/5318.aspx#81789</link><pubDate>Mon, 01 Mar 2004 00:13:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:81789</guid><dc:creator>Jay Patel</dc:creator><description>What about the inverse situation?&lt;br&gt;&lt;br&gt;I want to put an element/value at a specified XPath location in an xml document that may or may not contain the element.  Is there a way to do this without jumping through hoops?&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=81789" width="1" height="1"&gt;</description></item><item><title>re: Getting Path from an XmlNode</title><link>http://blogs.msdn.com/b/kaevans/archive/2003/04/10/5318.aspx#81784</link><pubDate>Mon, 01 Mar 2004 00:03:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:81784</guid><dc:creator>Jay Patel</dc:creator><description>What about the inverse situation?&lt;br&gt;&lt;br&gt;I want to put an element/value at a specified XPath location in an xml document that may or may not contain the element.  Is there a way to do this without jumping through hoops?&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=81784" width="1" height="1"&gt;</description></item></channel></rss>