xpath

getTextContent from Node with whitespace character normalization

Hi, I am working with XPATH, Java and want to extract some text out of one html page. The text is located under some div with some whitespace characters in between, like &nbsp; <br> etc. I want these to be converted into 'space' and 'newline' respectively while extracting. The method I am using to extract text is Element.getTextContent()...

Dynamically generate XPath expression using XML data

Hi! I would like to dynamically create XPath expressions in an XSL determined by data in an XML file. (i.e. the XML data is "concatenated" to create an XPath expression). Example of XML data: <criteria> <criterion>AAA</criterion> <criterion>BBB</criterion> <criterion>CCC</criterion> </criteria> Example of how I would lik...

Real World Application of XPath & XSLT

Can any professional please specify some real world application, where he / she has used this XPath & XSLT for any logic / view? It creates a great query among some of the people I've communicated with, and so I myself also wants to know about this. I wish that this question will create a starting point from where new developers will ta...

Output on namespaced xpath in java

I have the following code and have had some trouble with a specific field and it's output. The namespace is connected but doesn't seem to be outputting on the required field. Any info on this would be great. import org.w3c.dom.Document; import org.xml.sax.SAXException; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml....

case-insensitive matching in xpath?

For example, for the xml below <CATALOG> <CD title="Empire Burlesque"/> <CD title="empire burlesque"/> <CD title="EMPIRE BURLESQUE"/> <CD title="EmPiRe BuRLeSQuE"/> <CD title="Others"/> <CATALOG> How to match the first 4 records with xpath like //CD[@title='empire burlesque']. Is there xpath function to do this? Ot...

Nokogiri parsing Rackspace return using XPath in Rails

Hey guys, I'm using Nokogiri to parse a return from the Rackspace API so I'm using their sample code to response = server.get '/customers/'[email protected]_id.to_s+'/domains/', server.xml_format doc = Nokogiri::XML::parse response.body puts "xpath values" doc.xpath("//name").each do |node| puts node.text end As...

How to handle xpath in SQL query while programming in Java

I am trying to execute the SQL statement from my java application Due website restriction on url I have replaced http=htp for this post. SELECT DISTINCT(DID) FROM (SELECT e_id DID, xml_doc xml, rownum rn from employee_master_indexes)," + " table(XMLSequence(extract(xml,'//cf:SalesReport...

Parsing xml with php and xpath

Hey guys, I'm trying to parse an xml file to return a item with a specific id only, but having trouble making it work. here's what I have in php $xml_str = file_get_contents("test.xml"); $xml = simplexml_load_string($xml_str); $albid = $_GET['id']; $nodes = $xml->xpath('//library/book[@id=1]'); foreach($nodes as $node) { echo $node[...

I want to select all texts (including node names) under a node.

I currently have a xml file like this: <aaa> <b>I am a <i>boy</i></b>. </aaa> How can I get the exact string as: <b>I am a <i>boy</i></b>.? Thanks. ...

vb.net and html parsing

Currently I'm using the IHTMLDocument2 and IHTMLElementCollection to parse HTML, is there some way to parse it using some sort of xpath/selectors, something like elements = find_html_elements("a .link[rel=100]") ? ...

XPath - Quering two XML documents

I have have two xml docs: XML1: <Books> <Book id="11"> ....... <AuthorName/> </Book> ...... </Books> XML2: <Authors> <Author> <BookId>11</BookId> <AuthorName>Smith</AuthorName> </Author> </Authors> I'm trying to do the following: Get the value of XML2/Author/AuthorN...

get meta description tag with xpath

I need the content the description and the keywords tag content. I have this code, but dont write anything. Idea? $str = <<< EOD <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta name="description" content="text in the description tag" /> <meta name="keywords" content="text, in, the, keywords, tag" /> ...

Retrieving an element from XPath using text as basis

Terrible title, I know, but is there a way in XPath to get to a desired link by only knowing that the link is second going back from the last ellipsis? In this instance, the desired link is /2 <div class="page"> <a href="/1">1</a> <a href="/2">2</a> <a href="/3">3</a> ... <a href="/50">50</a> <a href="/51">51</a> <a href=...

XPath expression for a phpBB forum

I'm writing a Greasemonkey script, and I wanted to change the text of a forum post on a phpBB2 forum by using XPath to select the body of the post that occurs after a certain username, but the whole thing is a giant mess of tables. <tr> <td> <span class="name"> <a> <b>username</b> </span> <span></span> </td> ...

Remove all nodes from xml excluding specific nodes using XSLT

Hi, I have a bunch of xml files with a varying amount of data nodes in them and I want to change the files using XSLT to include only specific nodes. Example: <?xml version="1.0" encoding="UTF-8"?> <SomeName> <identifier> <UID> 1234 </UID> </identifier> <MainNode1> <SubNode1> <Subnode1a>DATA1a0</Subnode1a> ...

Retrieve specific preceding sibling nodes attributes

Is there an XPath way of recovering directly one specific attribute of preceding sibling nodes of an XML node using an XPath query? In the following example, I would like to retrieve the values of the alt attribute of each img nodes that precede the div element marked with the id=marker. <content> <img alt="1" src="file.gif" /> <im...

xpath multiple conditions

In selenium IDE, I need to find the 3rd link whose text is 'XXX' <tr> <td>clickAndWait</td> <td>//a[text()='XXX'][3]</td> <td></td> </tr> error: element not found, any idea? ...

selenium IDE clickAndWait xpath

In selenium IDE, I need to click on the nth link that has text 'XXX'. How can this be done? <tr> <td>clickAndWait</td> <td>//a[text()='XXX'][${link}]</td> <td></td> </tr> The above code says [error] Element //a[text()='XXX'][9] not found even though it's valid, ...

Is there any open source system for keyword search on XML documents?

I found lot of open source XML databases (TPOX, Timber , DBXML), but they are working on XPath and XQuery, I need a system which is developed for the purpose of "Keyword search on XML documents". ...

Render an url of type ?x=1&y=2 with xslt

Hello, Im trying to print, using a xslt sheet a url but im having problems with the chars = and &: This is the url that i want to render: <a href="whatever.aspx?x=1&y=2">whatever</a> Im getting that "=" is an unexpected token. How should i have to put the = and the & in a xslt sheet? Thanks in advance. Regards. Jose ...