xpath

How to get count number of SelectedNode with XPath in C#?

Hi, I am using HTMLAgilityPack in my application, and i want to get the item(node) count of SelectedNodes as the code below: HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); doc.LoadHtml(webBrowser1.DocumentText); var tagListe = doc.DocumentNode.SelectNodes("//a[@href]"); var divListe = doc.DocumentNode.SelectNodes...

Evaluate outer xpath-expression in xpath-predicate

Hi, i have a problem with a xpath-statement. Basically, the problem can be explained at the following code: <xsl:for-each select="/b1im:B1IMessage/b1im:Header/b1im:Z/SortInbound/group"> <!-- Check if entry from duplicate table is found for the current AccountingEntry --> <xsl:variable name="exter...

Xpath, how to select something that has a wildcard / partial match?

I'm new to xpath and am searching tutorials but can't seem to figure this out, I want to do a regex type of thing where I would select something based on it matching 'next', I wrote it below using regex syntax but am not sure how to do this in xpath, sorry for the newbie question but I am seemingly not able to find out how to do this.. t...

How could I optimize the XPath test not(previous-sibling::sect1) for testing whether this is the first sect1 child element?

I'm developing an XSLT 1.0 stylesheet (and apply it using xsltproc). One of the templates in my script should perform some special handling for the first <sect1> element in a given parent node and some for the last <sect1> element. Right now this special handling is implemented like this: <xsl:template match="sect1"> <xsl:if test="not...

XPath syntax to extract URL from HTMLNode using HTMLAgilityPack?

What is the proper XPath syntax to grab the value of the href attribute from the following HTMLNode: <a target="_blank" class="monkeys" href="http://someurl.com" id="123"> <span class="title">Monkeys are flying all over!</span> </a> ...

XPATH Query Recursion

I have an XML Document with Nodes that can appear recursively within other nodes of the same type. For example: <root> <Categories> <Category> <CategoryId>1</CategoryId> <CategoryName>Cat 1</CategoryName> <ChildCategories> <Category> <CategoryId>3</CategoryId> <CategoryName...

XPath Expression not working in HtmlAgilityPack!

Hi all, I know it may be of my noobness in XPath, but let me ask to make sure, cuz I've googled enough. I have a website and wanna get the news headings from it: www.farsnews.com (it is Persian) Using FireBug and FireXpath extensions under firefox and by hand I extract and test multiple Xpath expressions that matches the headings, suc...

xsl:sort an XML file using multiple elements

Hi All, I'm trying to sort a bunch of records in an XML file. The trick is that I need to sort using different elements for different nodes. To give a simplest example, I want to do this: given an xml file <?xml version="1.0" encoding="utf-8" ?> <buddies> <person> <nick>Jim</nick> <last>Zulkin</last> </person> <person> <first>Joe...

XPath Subset Selection

I have the following XML (which is actually HTML): <html> <h4>something</h4> <p>a</p> <p>b</p> <h4>otherthing</h4> <p>c</p> </html> Can a XPath selects the "p" nodes that are following siblings of the first "h4" node but not following siblings of second "h4" node (selecting "p" node a & b only)? ...

Using Nokogiri and XPath to get nodes with multiple attributes

I'm trying to use Nokogiri to parse an HTML file with some fairly eccentric markup. Specifically, I'm trying to grab divs which have both ids, multiple classes and styles defined. The markup looks something like this: <div id="foo"> <div id="bar" class="baz bang" style="display: block;"> <h2>title</h2> <dl> List of stu...

Question about selecting a child in xPath

Looking at w3schools for xPath (feel free to give me other references), you can select all the children of bookstore, but what if I wanted to only select the second book element? How can I do that? <?xml version="1.0" encoding="ISO-8859-1"?> <bookstore> <book> <title lang="eng">Harry Potter</title> <price>29.99</price> </book> <b...

Shortest XPath to find minimum/maximum of sibling dateTime nodes

Hi I have the following simple xml: <root> <item> <d>2002-05-30T09:00:00</d> </item> <item> <d>2005-05-30T09:00:00</d> </item> <item> <d>2003-05-30T09:00:00</d> </item> </root> Now I want to find the minimum or maximum dateTime node using XPath. My solution at the moment is: /root/item[not(number(translate(./d, 'TZ:-', ...

How to select a node's first child name? XPath

Hello, I have an XML from which I have to select the name of the child of one of the nodes. I'm kind of a beginner in this, so I didn't find the Xpath expression to do it. I know the level of the node (example Name from /Employee/Department/) but Department has children nodes of unknown names. I have to select the first child of Departme...

C# / XML - Question.

Hello everybody. I’ve got a problem witch I’ve been trying to solve almost for a week now, but it seems that, unfortunately, I can’t manage it by myself. Maybe somebody could help me. I’ve got this type of source XML: <data> <para1>24499</para1> <para2>32080148</para2> <para4>20e500cc6008d0f8ab1fd108b220ca261f85edd9</para4> <para6...

xPath doesn't retrieve HTML as part of the content

I parse a web page with the help of xPath and retrieving the content of the div element, it omits HTML that is contained in that div element. How to make it retrieve the whole content of the div element with HTML included? ...

xPath doesn't retrieve HTML as part of what is needed

Possible Duplicate: xPath doesn't retrieve HTML as part of the content I parse a web page with the help of xPath and retrieving the content of the div element, it omits HTML that is contained in that div element. How to make it retrieve the whole content of the div element with HTML included? ...

innerHTML in xPath?

Is there a way of retrieving HTML (and JavaScript) contained in a div element? ...

VB.NET: XPath problem

Hi, I have the follwing XML: <?xml version="1.0" encoding="utf-8" ?> <configuracoes> <gerais> <atualizacoes> <tipo>automática</tipo> <frequencia>diária</frequencia> </atualizacoes> </gerais> </configuracoes> And the code: Dim xPathNavigator As XPathNavigator Dim xPathNodeIterator As XPathNodeIterator xPathNav...

xPath: Why does the following not work?

Why does the following not work?: $dom = new DOMDocument(); @$dom->load('http://tinyurl.com/35cs96n'); $xpath = new DOMXPath($dom); $entries = $xpath->query('//table[@id="SubCategory_SubCategoryDataList"]/a/@href'); foreach ($entries as $entry) { echo $entry->nodeValue.'<br>'; } ...

How to get table data from tables using xpath

What XPATH query could i use to get the values from the 1st and 3rd tag for each row in a html table. The XPATH query i use is /table/tr/td[1]|td[3]. This only returns the values in the first tag for each row in a table. EXAMPLE I would expect to get the values bob,19,jane,11,cameron and 32 from the below table. But am only getting ...