Click here to Skip to main content
15,886,799 members
Everything / XPath

XPath

XPath

Great Reads

by _Asif_
Article helps reducing offsite development efforts by presenting a Mocking Layer for financial Middleware systems
by Anton Angelov
A tool for creating a report for author's articles for a specific year or from the beginning of time. Calculates the total number of views.
by Christiaan van Bergen
How to perform XPath queries on all lower case elements
by _Asif_
Framework helps resolve Template Codes present in any text at Runtime

Latest Articles

by FrankNight
This is just another web scraper written fully in .NET but finally without the use of mshtml!
by Christiaan van Bergen
How to perform XPath queries on all lower case elements
by Anton Angelov
A tool for creating a report for author's articles for a specific year or from the beginning of time. Calculates the total number of views.
by _Asif_
Article helps reducing offsite development efforts by presenting a Mocking Layer for financial Middleware systems

All Articles

Sort by Score

XPath 

5 Nov 2015 by _Asif_
Article helps reducing offsite development efforts by presenting a Mocking Layer for financial Middleware systems
11 Dec 2014 by Praveen Kumar Upadhyay
It is very small answer. You are doing a mistake. Module ID is MOO3 and not M003.As I have answered, So want my points:)
29 Oct 2011 by RaisKazi
Using "LINQ to XML".Have a look at below links.http://www.hookedonlinq.com/LINQtoXML5MinuteOverview.ashxhttp://www.joe-stevens.com/2010/01/08/linq-to-xml-tutorial/
10 Dec 2011 by RaviRanjanKr
The function ends-with() is not defined for XPath 1.0 *but only for XPath 2.0 and XQuery. so be sure whish XPath you are using.Reference LInk :-problem getting xpath function ends-with()[^]for more reference Link! have a look there-[XQuery 1.0 and XPath 2.0 Functions and Operators][^]
1 Feb 2012 by avishekrc
Hi,I have the following xmldocument named as memberDoc: - A 000000001 HIS TMH ...
3 Dec 2012 by CPallini
You have to handle the namespace in your code, e.g.XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable); nsmgr.AddNamespace("x", "urn:schemas-upnp-org:device-1-0"); string deviceType = doc.DocumentElement.SelectSingleNode("./x:device/x:deviceType",...
23 Jun 2013 by Sergey Alexandrovich Kryukov
There is no such thing as "mixed nodes". I think your difficulty is related to the case where you have the node first name "in the middle of other text". In fact, there is no such thing. From the DOM standpoint, the actual hierarchy looks like this:Element: "child" Text...
17 Jan 2017 by Anton Angelov
A tool for creating a report for author's articles for a specific year or from the beginning of time. Calculates the total number of views.
3 Apr 2018 by Christiaan van Bergen
How to perform XPath queries on all lower case elements
29 Oct 2011 by Amir Mahfoozi
In addition to other solutions, consider using Html Agility Pack :http://htmlagilitypack.codeplex.com/[^]
1 Feb 2012 by CPallini
What's wrong withstring retvalue = memberDoc.SelectSingleNode("ROOT/tblmembers/additionalinfo/patientadditionalinfo[@id='1']/race").InnerText;?
20 Mar 2012 by pietvredeveld
Don't see the error in you're xpath, but when parsing the line with filename10.xml the query returns to nodes (filename7.xml and filename9.xml). SelectSingleNode selects the first node (filename7.xml). So when you change XmlNode parent = root.SelectSingleNode("//tocEntry[@tabCount='" +...
15 Jul 2013 by Rambabu Sapa
Create A Messages.cs Class public class Message{ [Required] public string Name { get; set; } [Required] public string Description { get; set; }} XmlNodeList xmlDescriptionNodes = xmlDoc.GetElementsByTagName("message");if (xmlDescriptionNodes !=...
29 Jul 2013 by Prafulla Sahu
hi I am creating a sample login application which will authenticate all the valid users but, I am storing my username and passwords in a xml file. My code is working for valid credential as well as invalid credential like xpath injection code ' or '1' = '1. I am banging my head to overcome...
29 Jul 2013 by Joezer BH
Hi Prafulla, If you can deny usage of apostrophe in the string that you store, that would be an up front solution.The preferred solution of course is the usage of variables, this goes for SQL Injection as well as the less known XPath Injection.Read\watch more about Injection XPath...
7 Jan 2014 by PBGuy
HiHow to write xpath to get matching node based on the node's attributes and childs (if any) attributessingle xml node:
4 Feb 2014 by RhishikeshLathe
Please refer following code, i have added closing tags for Component tags:- string szXML = "" + "" + "" + ...
16 Mar 2014 by Ehsan Skardu
Hi,try this,var count = XDocument .Load("test.xml") .XPathSelectElements("//submenuid") .Count();
16 Mar 2014 by Krunal Rohit
You know this, XmlNodeList.Count[^], right ??XmlDocument.GetElementsByTagName[^] returns an XmlNodeList containing a list of all descendant elements that match the specified name.See the examples on given links. :)-KR
17 Jun 2014 by DrGrim
Hello ! I have this piece of code : require_once("Xpath.php"); //ini_set('xdebug.max_nesting_level', 200); scrape("http://filmehd.net/page/1"); set_time_limit(0); function scrape ($url) { $xpath = new XPATH($url); $get_image_src =...
10 Jun 2015 by Maciej Los
Yes, there is another way, via using XDocument class[^].string sloc = "http://192.168.6.22/Conditions.aspx";XDocument xdoc = XDocument.Load("fullfilename.xml");XNamespace xnsp = "http://www.sitemaps.org/schemas/sitemap/0.9";//return loc node - if existsvar qry =...
25 Jul 2023 by OriginalGriff
While we are more than willing to help those that are stuck, that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for...
12 Oct 2011 by Phillip Donegan
Struggling with this XPath expression, basically I need to extract the assembly name from a piece of xaml like this:
29 Oct 2011 by lovinlife045
I am reading the following XML structure, using - XPATH: "//root/node1[@value]/node2": I have to use data from "node1" if the data from "node2" satisfies certain conditions.If the conditions for "node2" information are met, how do I access the "node1" attribute?
10 Dec 2011 by lovinlife045
I'm trying to access XML variables that have attributes that end with "_abc".I ran across an Xpath option that I think might work.Here's the expression:SelectNodes("//FieldSpecs/FS//@*[ends-with(name(), \"abc\")]/");When I use it, I get the following error:ex.Message =...
11 Jan 2012 by Sujeet Pardeshi
Can we read values using xpath for complex xml file>???Consider the below xml file (copied at the end of question). I want to read PatchFile tag information using xpath.But when I used below expression it gives me result as null, XmlDocument doc = new XmlDocument(); ...
11 Jan 2012 by iliyash
//This is the Code to load your Xml file:XmlDocument doc = new XmlDocument(); doc.Load(@"E:\xmls\p_apsb11-16.xml");//Extract All nodes which contains data var xmlCompanyNodes = doc.GetElementsByTagName("PatchFile"); //Iteration on...
11 Jan 2012 by KiranBabu M
http://www.jav...
12 Jan 2012 by CPallini
It works for me if I remove the reference to the schema file (i.e. xmlns="Resource.xsd") in the Bulletin node.Have you such a file?
1 Feb 2012 by Amir Mahfoozi
I copied and pasted what you have provided into a file named "test.xml" (of course removed that extra dash from second line)and tested this code : XmlDocument rawXMLData = new XmlDocument(); StreamReader reader = new StreamReader(@"d:\test.xml"); ...
22 Feb 2012 by Ed Nutting
Since you can't use Response.Write (why though?) - why not save your file to a public location on the server (or a secured one) then send back the URL to that file (and any necessary security information) through hidden fields in your form (I assume you have one in your requested page...
8 Mar 2012 by newbieDVP
1.What do I have to do so that when display is clicked the table is refreshed? For now, whenever display is clicked a new table is created underneath the previous one.2.When the page loads for the first time I want the whole of the table to be displayed (ie the whole of my XML file(which...
21 May 2012 by fhdgbfbd
HiI use PHP to extract a number from a website by XPath. I realized that there is a problem with extraction of data from such an HTML code:the inside content...and i use such xpath query:/html/text()it does not recognize the inside...
23 May 2012 by keithl-3985036
I have xpath as an input and can produce the xpath'ed value using the various supported .net classes. However I also have a need to get the actual text file position where this value (or xpath'ed attribute/element) occurs. Thanks,Keith
10 Sep 2012 by avishekrc
Hi,I have an xml file which looks like following:...Now, I am getting the the document as XElement.I have to fetch the value of hosted attribute inside node.How acn I get that?I tried using...
10 Sep 2012 by Super Lloyd
does that inspires you? static void Main(string[] args) { string xml = @"..."; var xxml = XElement.Parse(xml); var list = from e in xxml.Descendants("det") from attr in...
22 Oct 2012 by sangeetha m
hi every body,actually i have doubt in message creation in biztalk server 2010?how the message recognize that corresponding schema ?eg: like rootnode or any thing else?so far i was used input schema as message type while creating message in an orchestraion.but i saw one...
22 Oct 2012 by Devang Vaja
hey Read thishttp://msdn.microsoft.com/en-us/library/aa559175.aspx[^]andhttp://msdn.microsoft.com/en-us/library/aa578053.aspx[^]andhttp://en.wikipedia.org/wiki/Microsoft_BizTalk_Server[^]and this is good article about biztalkUnderstanding BizTalk Server - In 47 Words Or Less[^]no...
14 Nov 2012 by Mustanseer Sadarwala
Hello,I am working on a customised control which is, simply put, a TreeView with ChecBoxes. The TreeView resides inside a ComboBox.The TreeView being inside a combobox is just a part of the requirement and I have already achieved the relation I wanted between them. My problem starts with...
3 Dec 2012 by Trapper-Hell
Hi,I have an XML file, and I need to extract some of its contents, however the file is non-standard XML and I am not familiar with XPath. I have tried researching on the internet however the presented solutions did not seem to work.Basically the XML content of the file is as...
11 Dec 2012 by Pepin z Hane
Hi,I am trying to select some elements from the xml document. Syntax of XPath is hard, I haven't found some good tutorial for it, but I have a program BaseX, which displays a XQuery route to the selected element. In a C# code I am trying to reach this element and add it to a list. but it...
11 Dec 2012 by CHill60
Article and sample code for using xPath Manipulate XML data with XPath and XmlDocument (C#)[^]andhttp://www.w3schools.com/xpath/[^]
23 Dec 2012 by engmebeed
I have this Xml: 8270 new new 899 20/12/2012 00:00:00 544 0 20/12/2012 12:06:27 ...
23 Dec 2012 by Krunal Rohit
No, we won't give you solution.. We can't work out for you like this.. You should try it by yourself.. If you got stuck somewhere, you can certainly come here.. But don't ask directly for code.. -Krunal R
21 Mar 2013 by devcode007
I need to select all 'z' nodes using jquery.I already know implemntation using Xpath(supported by FF,chrome) and Msxml2.DOMDocument(selectNodes--used in IE)I basically want to...
14 Apr 2013 by mazury
I've found a lot of articles about how to get node content by using simple xpath expresion and C#, for example:a) xpath/bookstore/author/first-nameb) C#string xpathExpression = /bookstore/author/first-name"nodes = navigator.Select(xpathExpression) I wonder how to get content that...
14 Apr 2013 by vijay__p
If your xml is like below then you can query it using Linqvar xml = @" ABCabcABC abcABC abc ABCABCABC"; var list = XDocument.Parse(xml).Descendants("ParaLine") .Select(x...
15 Apr 2013 by mazury
Problem is that file doesnt look like a simple xml. I mean abababababababa. One element include another element, here: >> So simple XPath syntax doesn't work...
17 May 2013 by Radzhab
I have two button - prev and next. When i run program it must show me first question with answers.Question in Qtextbox1. Answers in Atextbox1,Atextbox2,Atextbox3 ... /Key[1] show me first node. But i dont know how define count of nodes. first question answer1 ...
17 May 2013 by Sergey Alexandrovich Kryukov
Please start from here: http://msdn.microsoft.com/en-us/library/system.xml.xpath.aspx[^].—SA
17 May 2013 by onelopez
XmlDocument xdoc = new XmlDocument();xdoc.LoadXml("Your XML here");XmlNodeList xnodes = xdoc.SelectNodes("/Key");int count = xnodes.Count;foreach (XmlNode xnode in xnodes){ // TODO: Implement your code here}
17 May 2013 by debkumar@codeproject
You may use following xpath to get the count of 'Value' node in the xml.count(//Key/Value)To get the number of child elements in a node, we may use following xpath.count(//Key/*)
10 Aug 2013 by jimjimy
I have this xml : 10 بسم 1 0 1 1 4556 1 1 ...
11 Aug 2013 by jimjimy
$('.quranText .ayaNumber').each(function(){ var sname = $(this).siblings('.ayaText').attr("SName"); if($.trim($(this).text())=='﴿0﴾') $(this).closest('.aya').prepend('' +'' ...
12 Sep 2013 by Member 8764440
I want to convert leaf nodes in any xml document to its XPath expression using Java. Consider as an example xml document named x1 as,
18 Dec 2013 by PBGuy
Hi all, I want to query xml document with parameters likeparent element name - like searchattribute values - like search (attribute count around 4)I have a xpath string for combination of attributes alonehere it is : doc.SelectNodes("//*[contains(@jcr:mimeType,'tiff')...
17 Feb 2014 by slayasty
Hi, I have the following xpath: /html/body/div/div/div/div[2]/div/div/div/div[3]/div/table/tbody/tr/td[2]/afrom:
16 Mar 2014 by KUMAR619
Here I want a particular component count and edit the Xml header count How to do this at runtime using C#
15 May 2014 by Ranjan.D
Try using htmldoc.DocumentNode.SelectNodes("//l");
28 Jun 2014 by Bhagavan Raju M
Position: Passenger Side Front Color: Black Finish: Smooth / Paintable Part Brand: LatchWell Lifetime WarrantyI need xpath that should fetch...
27 Aug 2014 by DanielSatheesh
XML :20:FT13261793408907 N23B:CRED SA32A:130918USD111670,00 XSLT
27 Aug 2014 by _Asif_
Check thisDoes xslt have split() function?[^]
5 Aug 2015 by _Asif_
Framework helps resolve Template Codes present in any text at Runtime
11 Dec 2014 by carono
XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(@"C:\Users\aliu16\user.xml"); // TODO: Module[3] is ok , Module[@ID='M003'] does not work XmlNode nodeModule = xmlDoc.SelectSingleNode("//UserGroup[@ID='G001']/Module[@ID='M003']"); who can tell me...
8 Jan 2015 by Jitendra_rtpl
How to Evaluate below Expression using C# Code: xs:date($refPeriodEndDate)-xs:dayTimeDuration('P14D')i want result of this Expression using C# hw its work on c#.
7 Jan 2015 by Leo Chapiro
You can do it by using XPath, take a look: http://www.w3.org/TR/xpath-functions/#dt-dayTimeDuration[^]10.3.2 xs:dayTimeDuration[Definition] xs:dayTimeDuration is derived from xs:duration by restricting its lexical representation to contain only the days, hours, minutes and seconds...
10 Apr 2015 by Member 11581301
Hello everyone.I've been working on a project that requires me to zero in on a specific image on a website and stick it into a WinForms PictureBox. I have installed the HtmlAgilityPack, and I have the XPath for the image I need. How can I use C# to pull this image from the web and put it in...
25 May 2015 by Jitendra_rtpl
i want output from below Expiration xs:date($refPeriodEndDate)-xs:dayTimeDuration('P14D')i want to pass date as parameter and get output of Expiration. i have used "Saxon.Api" but got error - Invalid date "xs:date($refPeriodEndDate)-xs:..." (Year is less than four digits)if any...
27 May 2015 by dinesh_redhawk
Hello friends,We have a big XML file (>27MB) to be parsed. We had deserialized the XML file into a XmlData object. The data from the XML is perfectly saved in this XmlData object in a proper structure of classes and objects.Now, the goal here is to get the specific node data from the...
27 May 2015 by _Asif_
You can start by looking at below articleManipulate XML data with XPath and XmlDocument (C#)[^]
27 May 2015 by Acharya Raja Sekhar
Hi,I think you would like to deal with the deserialized object and want to find an object at specified path. Below code snippet might help you in doing this. class Program { static void Main(string[] args) { Student student = new Student { ID = 1,...
10 Jun 2015 by Afrikiko
I have this xml and I need to verify if a node exist, if a node does not exist i have to add it. I need to match on loc(http://192.168.6.22/Conditions.aspx) ...
24 Jul 2015 by Prem Anandh Natchatran
http://www.codeproject.com/Art...
27 Aug 2015 by Member 11762344
can someone explain to me, why an xpath expression as this:/*Never mind the nodeObj, its been successfully instantiated with root node added internally*/ $PageName = 'Home'; $nodeObj->xpath("./*[name() = (following-sibling::$PageName |...
18 Nov 2015 by Black_Rose
Hi allbelow is the output i am getting after running a command system:!:0:root,appdetI want to extract only "root,appdet" from the line data.Please tell me how to do this..Thank you
18 Nov 2015 by George Jonsson
You can use a regular expression to solve this problem.See XQuery and XPath Regular Expressions[^]Specifically look into fn:tokenize(subject, pattern, flags)The regex in this case could be:(?[a-z]+,[a-z]+)Note: This regex will only work under the specific circumstances you...
19 Nov 2015 by George Jonsson
Have a look at this list of XPath functions: XSLT, XPath, and XQuery Functions[^]Specifically look intofn:substring-before(string1,string2)fn:substring-after(string1,string2)fn:tokenize(string,pattern)and then pick a winner.
23 Nov 2015 by jinesh sam
Hi friends,I need to validate an xml file. My requirement is Coupon should come first then MaturityDate if its not coming in the specified order its an error,How can i achieve this? will the xpath works? or any other better alternative.Please help var ProjectedIncomePosition =...
23 Nov 2015 by Manas_Kumar
Try with below code:string xmlData = @"STK00.59false";// Getting all elementsIEnumerable...
23 Nov 2015 by phil.o
What you are trying to do is purely the role of a .xsd xml schema definition, and should be handled this way.Defining a schema would allow you to clearly and definitely define the valid content of your xml file (including tags, how much of them are allowed, and their respective orders), and...
31 Dec 2015 by snavece
I have a list of XPaths and I wish to get collection of all nodes from one node to the next. I am using HTML Agility Pack, but I suspect that any correct XPathQuery will work regardless of the specific package being used.for (int i = 1; i
26 May 2016 by Bloody Chicken
xml file is like as below...i want to get two data 'user_name' and 'email'using xpathnavigator in c#.......................but can't... result is nothing...------------------------------------------------------------------------------------------
26 May 2016 by George Jonsson
Alternative way to do it.Using a DataSet will automatically give you the table structure.XDocument xDoc = XDocument.Load('your file name');XElement xeMsg = xDoc.Element(XName.Get("MSG", "http://tempuri.org/"));XElement xeRd = xeMsg.Element(XName.Get("RD",...
6 Jun 2016 by Mohideenmeera
up vote 50 down vote ...
11 Oct 2016 by #realJSOP
Maybe the document being returned has malformed html in it. Try putting your code inside a try/catch block to see what happens.Also, try reinstantiating the web client INSIDE your WebDataFromPage method.Finally, what's the point is using async code when you're waiting for the code to...
25 Oct 2017 by Jagga Lyalpuria
I am stuck in a problem i just want to extract data from x-path attribute selector this is the div and span who's inner text want to show please help me out. I am also performing this option in 16 times in a for each loop. Required 10 marla old house in any block of bahria town I...
25 Oct 2017 by Richard Deeming
The obvious problem is that the you've shown has a class of l - a lower-case L - whereas you're searching for a class of 1. You're also trying to select an element called title, which doesn't exist; the title shown is an attribute. var name =...
25 Oct 2017 by Gedarius
did you try jQuery selector? i didn't test but something like this should work $("div.l > span.ls_h_desc").val()
5 Oct 2020 by nadimr
I have written T-SQL code to update XML records in a potentially very large table (let's say millions of rows) with each row having an XML column. The code changes the values of all nodes in the XML that match a user-defined XPath expression. So...
11 Mar 2021 by Talha Sial
I'm trying to scrap the names of universities and their links from this website **https://www.hec.gov.pk/english/universities/pages/recognised.aspx#k=** What I want for my scrapper to do is scrape the names of university from the first page,...
3 Jun 2021 by Member 13735228
I have a large set of XML data (450,000 rows) returned by an API that I am attempting to roll up into a summary. I thought of using LiNQ with an embedded xPath call to return the counts. Maybe my approach is incorrect??? Any suggestions would...
25 Jun 2021 by sriindhu
Selenium xpath Please let me know to select the input tag which does not contain any text in it using dynamic xpath. What I have tried: Meanwhile I can't use...
25 Jun 2021 by Richard Deeming
Try: //div/input[text()=''] or: //div/input[not(text())]
15 Dec 2021 by Landon Williams
url = "https://dashboard.heroku.com/new?button-url=https%3A%2F%2Fgithub.com%2Ftitaniumnetwork-dev%2Falloy&template=https%3A%2F%2Fgithub.com%2Ftitaniumnetwork-dev%2Falloy%2Ftree%2Fmaster" options = Options() options.add_argument('--headless')...
21 May 2022 by Richard MacCutchan
Use the String method: String.IsNullOrWhiteSpace(String) Method (System) | Microsoft Docs[^]
1 Nov 2023 by MichaelEriksen
I am trying to get a list of nodes as a result of a XPath in JavaScript, but do not know how to do it. Unfortunately, I have tried a lot without any knowledge of how to do it - the alert does not come. So how to get a list of nodes from...
31 Oct 2023 by M Imran Ansari
To retrieve a list of nodes using XPath in JavaScript, you can try using the document.evaluate() method. This updated code snippet will select all cac:ContractDocumentReference nodes with cbc:ID equal to '234' from the provided XML. Adjust the...
3 Jul 2019 by FrankNight
This is just another web scraper written fully in .NET but finally without the use of mshtml!
8 Jul 2011 by rj45
For performance reasons, I decided to write my own XML parser.