xpath

Search with XPath in VB.NEt

I have a Xml file, ( actually HTML tags ) , I want to use the SelectNodes method to get ANY node/tag containing a keyword. The node name can be anything <td> , <div> <p>. What is the XPath to get any node which contains a keyword? ...

is there a way to emulate correctly replace function on XPATH 1?

Hi everybody, i have this funtion which tries to replace dots and/or - with _ I m limited to use xpath 1 so replace function is NOT an option. The template works not to much fine because if i use something like this: FOO-BAR.THING-MADRID.html it gives me out on screen this thing: FOO-BAR.THING-MADRID.html the middle dot is not repla...

Use XPath with PHP's SimpleXML to find nodes containing a String

Hi! I try to use SimpleXML in combination with XPath to find nodes which contain a certain string. <?php $xhtml = <<<EOC <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de"> <head> <meta http-e...

XPath Expression Problem

I have the following HTML snippet, http://paste.enzotools.org/show/1209/ , and I want to extract the tag that has a text() descendant with the value of "172.80" (it's the fourth node from that snippet). My attempts so far have been: 'descendant::td[@class="roomPrice figure" and contains(descendant::text(), "172.80")]' 'descendant::td[...

Siblings with dom/xpath

Hi, Have been trying several days to parse the following html code (notice that there is not a real hierarchal tree structure). Everything is pretty much on the same level. <p><span class='one'>week number</span></p> <p><span class='two'>day of the week</span></p> <table class='spreadsheet'> table data </table> <p><span class='two'>a...

XPath query for counting nodes

I want to use xpath to count occurances of certain node in xml document. What would I use? For ex: If I wanted to get second occurance of movie node I'd use movie[2]. How do I get total number of movie node occurances in document? ...

Succinct version of simplexml/xpath?

Currently I have: $content = ($propXml->xpath('//content/section[@name="accommodations"]/content')); $content = is_array($content) && (count($content)>0)?(string)$content[0]:false; echo $content; Is there a more succinct way of doing this? It would be shorter if PHP had the ability to automatically access an assigned array, but I hav...

Finding a string that is split by multiple html tags

I am using Xpath to find a list of strings in an HTML document. The strings appear when you type into a text box, to suggest possible results - in other words, it's auto-complete. The problem is, I'm trying to retrieve the whole list of auto-complete suggestions, the results are all split up by <strong> tags. To give a couple examples...

xPath problem matching specific attribute

Hey, I've got the following HTML that I am trying to pull the state attribute out of. <div id="content" class="listing mapListing" longitude="123.0000" latitude="-123.0000" listingName="business" business=";12345678;;;;evar01=name" state="NSW" events="1"> I'm trying to match using the following PHP, which doesn't return "NSW". $xpat...

Using XPath/XQuery to create child nodes in a SQL column

I have a sql table with an xml column named CasingRules, which would contain data such as: <root> <Item> <RegularExpression>^Mc[A-Z,a-z]*</RegularExpression> <Format>ULU</Format> </Item> <Item> <RegularExpression>^Mac[A-Z,a-z]*</RegularExpression> <Format>ULLU</Format> </Item> </root> I'm trying to use MS SQL's...

xPath: How to check if a attribute exists?

Given the following xml, how do I write an xPath query to pull nodes where attribute the foo exists?: <node1> <node2> <node3 foo='bar'></node3> <node3></node3> <node3 bar='foo'></node> <node3 foo='foobar'></node3> </node2> </node1> ...

cannot find custom namespace in xml

Hi all, Could someone please help me out with this. I need to find the gml:pos namespace in the xml. But, very important! - in the $item part off the loop I really have no clue how to get this done. The namespace is in another custom namespace according to google-api docs. $feed = simplexml_load_string($feedXml); foreach ($feed->en...

XPath query for a node

I should be doing something wrong. What is the XPath query for all nodes named "name" under display-name? I am using libxml2. <?xml version="1.0" encoding="UTF-8"?> <description xmlns="http://openoffice.org/extensions/description/2006" xmlns:d="http://openoffice.org/extensions/description/2006" xmlns:xlink="http://www.w3.org/1999/xlink...

XPath and *.csproj

I am for sure missing some important detail here. I just cannot make .NET's XPath work with Visual Studio project files. Let's load an xml document: var doc = new XmlDocument(); doc.Load("blah/blah.csproj"); Now execute my query: var nodes = doc.SelectNodes("//ItemGroup"); Console.WriteLine(nodes.Count); // whoops, zero Of course,...

Using htmlagility xpath's to find webdriver elements

I'm using htmlagility pack to locate elements in large loops through tables because its much faster than using the native methods provided through webdriver. After locating a specific element through the looping I'm getting its xpath, then feeding that to webdriver to return an element. However I'm getting an exception; OpenQA.Sel...

Oracle XSLT: default namespace results in empty tags

I think the best way to ask this question is: How do I specify a default namespace for the root element in the output? Doing this: <xsl:template match="/"> <r xmlns:s"http://www.mycompany.com/s/schema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.mycompany.com/default/schema" > .... .... Gives me an ...

XPath query for exact match

Hi, I'd like to search an xml doc (or rather Element with sub elements) for a string. It needs to be an exact match. Here's a sample of the xml <Car> <Make value="German\Opel"/> <Make value="German\Benz"/> <Make value="Japanese\Nissan"/> </Car> ...

Xpath: find an element value from a match of id attribute to id anchor

Hi, I would like to find the value of an element matched on id attribute for which I only have the ref - the bit with #, the anchor. I am looking for the value of partyId: < party id="partyA" > < partyId >THEID< /partyId > but to get there I only have the href from the following < MyData > < MyReference href="#partyA" /> ...

Why this XPath sentence is wrong for Firefox?

click(new XPath("/HTML[1]/BODY[1]/DIV[1]/DIV[2]/DIV[1]/DIV[2]/DIV[1]/DIV[2]/DIV[1]/DIV[1]/DIV[2]/DIV[1]/DIV[1]/DIV[1]/DIV[1]/DIV[2]/DIV[1]/DIV[1]/DIV[1]/DIV[1]/DIV[1]/DIV[2]/DIV[1]/SPAN[1]/SPAN[2]/#text[1]")); ..or var foo = document.evaluate("/HTML[1]/BODY[1]/DIV[1]/DIV[2]/DIV[1]/DIV[2]/DIV[1]/DIV[2]/DIV[1]/DIV[1]/DIV[2]/DIV[1]/DIV[1...

Multidimensional Array

I have 2 items that are related to each other that need to be accessed separately. The title of a book and how many pages it has. I have made an array for the titles, but what is the best way to link the number of pages in that book to that title? I was thinking of the following but I don't see how to access the page count. <string-arr...