.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

VB .Net XmlElement selectNodes() XPath

Posted By:      Posted Date: September 03, 2010    Points: 0   Category :ASP.Net
Helo, I tried to use the XmlElement 's selectNodes() method. This method accepts as a parameter the XPath string to select the proper node under that element http://msdn.microsoft.com/library/d...nodestopic2.asp when i tried this with the path "//*" I get all the nodes as I expected but when I used "//Response" which is one of the nodes return ealier I get empty XmlNodeList Why is it that the XPath is not working? rgds. ps : my code Dim nodes As XmlNodeList nodes = myxmlelement.SelectNodes("//Response")

View Complete Post

More Related Resource Links

xpath issue


Hi i am using xpath to loop through each node,

the xml is below i can get the value of "link" but i cant get the thumbnail value, have you got any ideas how i can do this, my code is below.



     <link>test 1</link>
     <media:thumbnail url="http://test.com/image.jpg" height="75" width="75" />



     <link>test 2</link>
     <media:thumbnail url="http://test.com/image.jpg" height="75" width="75" />


public void FindLinks(XPathNavigator p_xPathNav, DataTable dt)
            //run the XPath query
            XPathNodeIterator xPathIt = p_xPathNav.Select("//item");

            //use the

Real-World XML: Manipulate XML Data Easily with the XPath and XSLT APIs in the .NET Framework


XPath is emerging as a universal query language. With XPath, you can identify and process a group of related nodes in XML-based data sources. XPath provides an infrastructure that is integral to XML support in the .NET Framework. The XPath navigation model is even used under the hood of the XSLT processor. In this article, the author reviews the implementation details of the XPath navigator and the XSLT processor and includes practical examples such as asynchronous transformations, sorted node-sets, and ASP.NET server-side transformations.

Dino Esposito

MSDN Magazine July 2003

The XML Files: Introducing XPath 2.0


Over two years ago in one of the first installments of this column, I wrote about XPath version 1. 0 (see The XML Files: Addressing Infosets with XPath for a quick review). As stated in the original specification: "XPath is a language for addressing parts of an XML document.

Aaron Skonnard

MSDN Magazine January 2003

Is it possible to select every xpath from an XML message?

Hello, I have a need to read an XML message and produce output that contains every XPath encountered. I currently have an XQuery that can successfully read through an XML Message and list out a tabular row for each node encountered in order. That Xquery looks like this: select cast(t.c.query('fn:local-name(.)[1]') as varchar(100)) as Node_Name from dbo.my_table cross apply my_xml_column.nodes('//*') t(c) I'm trying to extend the XQuery above to list out each entire XPath encountered in order (each XPath output row would end with the node from the output produced from my existing XQuery) ... can't seem to get there. Any help would be appreciated. Thanks. Dave

How to use a dynamic XPath with XQuery?

HI, I've a problem with dynamic XPath-Expressions used in Xquery functions as shown below.DECLARE @XML1 xml DECLARE @XPath as varchar(200) SET @XML1='<Root> <Device> <Inspection> <Status>OK</Status> </Inspection> </Device> </Root>' -- This returns the correct results SELECT @XML1.query('/Root[1]/Device[1]/Inspection[1]/Status[1]') SELECT @XML1.value('/Root[1]/Device[1]/Inspection[1]/Status[1]','varchar(5)') -- This returns the Xpath-Expression itself or a part of it and not the expected results SET @XPath='/Root[1]/Device[1]/Inspection[1]/Status[1]' SELECT @XML1.query('sql:variable("@XPath")') SELECT @XML1.value('sql:variable("@XPath")','varchar(5)')What's wrong with the use of "sql:variable"Thanks in AdvanceRaimund

Ok, XPath expert... how to access this node??

I need to alter the "something else" attribute in the xml below. The only way the correct 'category' node can be found is by finding the right 'subCat', in this case the subcat with a subCatTypeCode equal to 'B'.<root> <category> <subCat subCatTypeCode='A' /> <features> <item id='5678' attribute='something'/> </features> </category> <category> <subCat subCatTypeCode='B' /> <features> <item id='5678' attribute='something else'/> </features> </category> </root>  If you try to do something like the below, you will end up with the FIRST 'item' node.  XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(sXML); XmlNode node = xmlDoc.SelectSingleNode("//category/subCat[@subCatTypeCode='B']").ParentNode.SelectSingleNode("//features/item[@id='5678']"); Please... how to do this?  Thanks.

xmldatasource and xpath expression evaluation

Hi, I am working with XMLdatasource and trying to consume a XML file. Now problem is there are scenarios when a link is not available in the xml file. Like in the e.g. below: <a href='<%# XPath("link") %>' >  </a>  say "link" can or cannot be there in the file. Now when "link" is missing, this expression throws exception. How can I handle this exception so that it continues loading page normally or can I check "link" existence somehow? Thanks.

determining if node contains a value using XPath

I have this document:<doc>    <float name="score">1.0</float>    <arr name="services">        <str>Fotoreport</str>        <str>Exclusive</str>    </arr></doc>I want to check if the node <arr name="services"> contains the value "Fotoreport"I now have this:XPath("arr[@name=""services""]/str[@Fotoreport]")But, that doesnt work....what is the correct XPath?

Unable to store for xml Xpath result in a variable

HI ALL, Unable to store the results of xml  reults into a varible , it  throws an error declare   @r varchar(1000) set   @r =( WITH   XMLNAMESPACES (     'http://schemas.microsoft.com/analysisservices/2003/engine/2/2' as ddl2_2   , 'http://schemas.microsoft.com/analysisservices/2003/engine/2' as ddl2   ,'http://www.w3.org/2001/XMLSchema-instance' as xsi   ,'http://www.w3.org/2001/XMLSchema' as xsd ) select   DatabaseID "Object/DatabaseID" , CubeID "Object/CubeID" , MeasureGroupID "Object/MeasureGroupID" , PartitionID "Object/PartitionID" , DimensionID "Object/DimensionID" , ProcessType "Type" , WriteBackTableCreation "WriteBackTableCreation" , Parallel "parallel"   from #ega WHERE   ProcessingGroupID = 3 FOR   XML PATH('Process'))
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend