xpath

nokogiri: why is this an invalid xpath ?

//br/preceding-sibling::normalize-space(text()) i am getting invalid xpath expression with nokogiri ...

how to find all the child nodes inside the matched elements (including text nodes) ?

in jquery its quite simple for instance $("br").parent().contents().each(function() { but for nokogiri, xpath, its not working out quite well var = doc.xpath('//br/following-sibling::text()|//br/preceding-sibling::text()').map do |fruit| fruit.to_s.strip end ...

Is it possible to use a Dynamic xPath expression in a xslt style sheet?

I'd like to use the value of an xslt parameter in an xpath expression. Specifically, as part of a not() call in an <xsl:if expression. <xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; <!-- my_param contains a string '/foo/bar', passed in from ant --> <!-- the 'no' is just a default value --> <xsl:par...

Extracting info from html using PHP(XPath), PHP/Python(Regexp) or Python(XPath)

I have approx. 40k+ html documents where I need to extract information from. I have tried to do so using PHP+Tidy(because most files are not well-formed)+DOMDocument+XPath but it is extremely slow.... I am advised to use regexp but the html files are not marked up semantically (table based layout, with meaning-less tag/classes used every...

XSLT - activate xpath function in XSLT

Hi, i have the following xml, which is the result of runnig xslt: <?xml version="1.0" encoding="UTF-8"?> <toc xmlns:fn="http://www.w3.org/2004/07/xpath-functions" label="Sample Table of Contents"> <topic label="Title1" href="Ref1#ref1"> <topic label="Title 2" href="Ref2#ref2"> <topic label="Title3" href="Ref3#ref3"/> ...

PHP XPATH of HTML document omitting all tags. I want to keep them

I am parsing a HTML document with XPATH and I want to keep all the inner html tags. The html in question is a unordered list with many list elements. <ul id="adPoint1"><li>Business</li><li>Contract</li></ul> I am parsing the document using the following PHP code $dom = new DOMDocument(); @$dom->loadHTML($output); $this->xpath = new ...

xpath functions not supported in jquery.

I have the following xpath that I need to run, but Jquery doesn't support the functions....so how can i actually make this work in jquery ? $("//*[br]/text()[string-length(normalize-space()) != 0]").each( .... ...

xpath locator works in FF3, but won't work in IE7

After switching from firefox testing to internet explorer testing, some elements couldn't be found by selenium anymore. i tracked down one locator: xpath=(//a[@class='someclass'])[2] While it works as it should under firefox, it could not find this element in ie. What alternatives do i have now? JS DOM? CSS Selector? How would this l...

How to get a particular attribute from XML element in SQL Server

I have something like the following XML in a column of a table: <?xml version="1.0" encoding="utf-8"?> <container> <param name="paramA" value="valueA" /> <param name="paramB" value="valueB" /> ... </container> I am trying to get the valueB part out of the XML via TSQL So far I am getting the right node, but now I can not figure...

XPath query for getting the right element

Hi stackoverflowers... What XPath Query will get me the role id of the role that has a subelement with a name element "Participant"... i.e. the answer i want is 11. How do i get that answer using XPath on this XML? <?xml version="1.0" ?> <qdbapi> <action>API_GetRoleInfo</action> <errcode>0</errcode> <errtext>No error</errtext> <roles> ...

What pure Python library should I use to scrape a website?

I currently have some Ruby code used to scrape some websites. I was using Ruby because at the time I was using Ruby on Rails for a site, and it just made sense. Now I'm trying to port this over to Google App Engine, and keep getting stuck. I've ported Python Mechanize to work with Google App Engine, but it doesn't support DOM inspecti...

Pulling out a full node with child nodes using XPath

I'm using XPath to select an section from an HTML page. However when I use XPath to extract the node, it correctly selects only the text surrounding the HTML tags and not the HTML tags themselves. Sample HTML <body> <div> At first glance you may ask, &#8220;what <i>exactly</i> do you mean?&#8221; It means that we want ...

Delphi and XQuery/XPath 2.0?

How do people use XQuery and/or XPath 2.0 from Delphi? I've got MSXML v6.0 working from Delphi, so any sufficiently documented COM-implementation will work. What's your favorite? ...

xpath find specific link in page

I'm trying to get the email to a friend link from this page using xpath. http://www.guardian.co.uk/education/2009/oct/14/30000-miss-university-place The link itself is wrapped up in tags like this <li><a class="rollover sendlink" href="http://www.guardian.co.uk/email/354237257" title="Opens an email form" name="&lid={pageToolbo...

XML Parsing using JavaScript

Hey all, Here's an XML snippet: <appSettings> <add key="val1" value="val2"/> The XML document is loaded in memory, ready to be parsed. How would you get and write the value of "val2" to the web page? Thanks, rodchar Post Comments: I'm getting .selectSingleNode is not a function: <script type="text/javascript"> if (window.X...

Getting certain attribute value in an element with multiple values using xpath PHP

Hi, i'm playing around with flickr API lately and having difficulties in parsing their response to extract the info i need, here is a sample response: − <rsp stat="ok"> − <sizes canblog="0" canprint="0" candownload="1"> <size label="Square" width="75" height="75" source="http://farm3.static.flickr.com/2306/1555710063_d2c1e7e7cd_s.jpg" ...

How to get path of an element in lxml?

Hello, I'm searching in a HTML document using XPath from lxml in python. How can I get the path to a certain element? Here's the example from ruby nokogiri: page.xpath('//text()').each do |textnode| path = textnode.path puts path end print for example '/html/body/div/div[1]/div[1]/p/text()[1]' and this is the string I want to ...

python, lxml and xpath - html table parsing

Hello, I 'am new to lxml, quite new to python and could not find a solution to the following: I need to import a few tables with 3 columns and an undefined number of rows starting at row 3. When the second column of any row is empty, this row is discarded and the processing of the table is aborted. The following code prints the table...

How do we determine if an XPath expression results in a node-set?

Given that any type other than a node-set cannot be coerced into a node-set, how do we determine,at runtime, if the result of an XPath expression is a node-set? Although I guess it shouldn't matter, I'm using Sablotron for processing. Thanks in advance. ...

Parsing XML: Colon in my element causes XPath to miss it

I have an XML document that I load in and try to search with XPath. The root node in this file is <t:Transmission xmlns:t='urn:InboundShipment'> and the file end is properly closed with </t:Transmission>. My problem is that I cannot walk the tree without using a descendant axis. In other words, I can do: SelectSingleNode("//Transactio...