Click here to Skip to main content
15,892,965 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 Updated

XPath 

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...
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
27 May 2015 by _Asif_
You can start by looking at below articleManipulate XML data with XPath and XmlDocument (C#)[^]
5 Nov 2015 by _Asif_
Article helps reducing offsite development efforts by presenting a Mocking Layer for financial Middleware systems
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) ...
14 Jun 2015 by aksjustcool
I have a DataTable where the first Column contains the link for another page(that is done by JavaScript). I need to call these link one by one and get the data from the page. But I am unable to load it into webbrowser one by one.Only the last page is being load. Is there any alternative or...
29 Oct 2011 by Amir Mahfoozi
In addition to other solutions, consider using Html Agility Pack :http://htmlagilitypack.codeplex.com/[^]
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 amtechq8
Below is my asp pages trying for xml request/responseRequest.asp (from client) 123" Set http = CreateObject("MSXML2.ServerXMLHTTP") http.open "GET", "http://test.com/response.asp?xml_request=" & pXML, 0 ...
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.
1 Feb 2012 by avishekrc
Hi,I have the following xmldocument named as memberDoc: - A 000000001 HIS TMH ...
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...
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...
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
19 Nov 2015 by Black_Rose
Hi allI am getting the values like thisabc,bcanow i want to write it like thisabcbcaPlease tell mw how to do this
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...------------------------------------------------------------------------------------------
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...
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/[^]
3 Apr 2018 by Christiaan van Bergen
How to perform XPath queries on all lower case elements
22 Jun 2013 by codeninja-C#
Hi,can you help to find the Mixed nodes in the given XML?XMLword text first name word textword textXSLT
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 CPallini
What's wrong withstring retvalue = memberDoc.SelectSingleNode("ROOT/tblmembers/additionalinfo/patientadditionalinfo[@id='1']/race").InnerText;?
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",...
27 Aug 2014 by DanielSatheesh
XML :20:FT13261793408907 N23B:CRED SA32A:130918USD111670,00 XSLT
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/*)
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...
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...
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...
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 =...
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...
16 Mar 2014 by Ehsan Skardu
Hi,try this,var count = XDocument .Load("test.xml") .XPathSelectElements("//submenuid") .Count();
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 ...
22 Dec 2014 by ergohack
An implementation of parameterized XPaths in WPF/XAML.
11 Oct 2016 by Faran Saleem
Hello,I am performing web scraping but xpath returns null.I am trying this since yesterday and when i ran my code in the morning today it returned me unformatted result i am not sure how because since then it is returning null value again. I do not know what the problem is. I would highly...
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...
3 Jul 2019 by FrankNight
This is just another web scraper written fully in .NET but finally without the use of mshtml!
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()
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.
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",...
1 Dec 2003 by goerge@Mailinator.com
An application to visualize XPath Queries
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...
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...
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('' +'' ...
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 =...
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#.
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...
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...
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
11 Jan 2012 by KiranBabu M
http://www.jav...
2 Dec 2012 by Krunal Rohit
Simple example is given over here[^]...
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
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
4 Feb 2014 by KUMAR619
How to find missing values in XML file using C#
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 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')...
26 Jul 2023 by Larry Chapman II
The following XML document is stored in an object called "x": Tove Jani Reminder Don't forget me this weekend What will each of the following...
26 Jul 2023 by Larry Chapman II
Okay so, as far as I've come along this is essentially what I'm trying to do here: something else should be showing var parser, xmlDoc; var text =...
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...
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 =...
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...
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 =...
23 Nov 2015 by Manas_Kumar
Try with below code:string xmlData = @"STK00.59false";// Getting all elementsIEnumerable...
10 Apr 2015 by Mario Z
Hi, here is how you can do that:var htmlDocument = new HtmlWeb().Load("URL of website you are targeting...");var imageNode = htmlDocument.DocumentNode.SelectSingleNode("XPath of image you are targeting...");string imagePath = imageNode.Attributes["src"].Value;var imageStream =...
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...
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...
4 Apr 2014 by Member 10462229
I have an XML document i am trying to parse with HTML Agility Pack using XPath. This is my code for getting to the elementsHtmlDocument htmldoc = new HtmlDocument();htmldoc.Load(fileName);HtmlNodeCollection nodes = htmldoc.DocumentNode.SelectNodes("feed/l");This is my XML...
24 Jul 2015 by Member 11530690
i have one code html:
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...
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 |...
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...
3 Jul 2018 by Member 13882901
For the xml file (1.xml)
21 May 2022 by Member 15403309
Quote: How to sort an array like this ? I am getting array of strings with length but some of them are empty in markup. I need to avoid them. [0]=> string(6) " " [1]=> string(5) " " [2]=> string(1) " " [3]=> string(11) "The problem" ...
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,
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...
6 Jun 2016 by Mohideenmeera
up vote 50 down vote ...
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...
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...
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...
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}
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...
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')...
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:
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...
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...
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:
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='" +...
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...
21 Mar 2013 by Prasad Khandekar
Hello,Below is a small demo HTML. It shows how to process XML using a mix of JQuery & JavaScript.var xml = '';var xmlDoc = $.parseXML( xml );var znodes = $("z",...
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:)
24 Jul 2015 by Prem Anandh Natchatran
http://www.codeproject.com/Art...
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 ...
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/
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 !=...
15 May 2014 by Ranjan.D
Try using htmldoc.DocumentNode.SelectNodes("//l");