xpath

What's wrong with my xml?

i have the following xml: <messageContent xmlns="http://tempuri.org/" > <Message type="MappedMessage" > <Properties RequestId="Point-CurveRequest-8326ad44-a1cd-4a96-b4ef-1c4ad213d940" Action="getParCurves" EESId="EESID:NY:20100128:BASE" Currency="USD" Index="INX" /> <Body></Body> </Message> </messageContent> and then i have this q...

Using XQuery/XPath to get the attribute value of an element's parent node

Given this xml document: <?xml version="1.0" encoding="UTF-8"?> <mydoc> <foo f="fooattr"> <bar r="barattr1"> <baz z="bazattr1">this is the first baz</baz> </bar> <bar r="barattr2"> <baz z="bazattr2">this is the second baz</baz> </bar> </f...

how to get horizontal depth of a node ?

note i made up the term horizontal depth to measure the sub-dimension of a node within a tree. so imagine a which would have xpath something like /html/table/tbody/tr/td, and "horizontal depth" of 5 i am trying to see if there is a way to identify and select elements based on this horizontal depth. how can i find the maximum depth ? ...

How can i control Item Count while reading xml Xpath() command in C#

Hi , i have got a news section in my website. I can Insert news to my XML file , than shows them in main page.There are so many news in my xml file.I showing them with Xpath("content") command.So i can restrict item count with xPath command.Is there anyway to Paging or Max Items option for this usage ? XML File; <?xml version="1.0" e...

Custom providers using XML as their data store - should I use XPath/XSLT or DOM?

Hi I’d like to learn how to create custom providers ( say custom membership provider or custom profiles ) that use XML as their data store. Is ( using C# ) best way to accomplish this using XPath/XSLT or DOM? thanx ...

Extracting context from a set point in the middle of an HTML file.

I have some HTML, and I'm extracting a snippet at a certain point (an inline image), but I'd like to show some context around this image. I'm using PHP, and I know that both Symfony and Wordpress provide functions for dealing with what happens when you chop up text in the middle of some HTML (it closes all open tags), but nothing for de...

how to get the maximum depth of an html tree ?

say i have an html page parsed via Nokogiri. how can i find the maximum depth of the tree ? do i iterate through each element and count how many ancestors it has ? is there a more efficient approach ? ...

How can i get Last xx item from XML file with Xpath() query in C#?

Hi, how can i get Last added 5 item's node from my XML file with Xpath ? this is not what i want .. its gives First 5 item , i wanna get last 5 item XPath="/newsSection/news[position()<=5] thanx for ur helps. ...

Access an element's parent with PHP's SimpleXML?

I'm iterating through a set of SimpleXML objects, and I can't figure out how to access each object's parent node. Here's what I want: $divs = simplexml->xpath("//div"); foreach ($divs as $div) { $parent_div = $div->get_parent_node(); // Sadly, there's no such function. } Seems like there must be a fairly easy way to do this. ...

Render sparse matrix with Jasper Reports

How can I create a table containing empty cells from data organized in rows and lines? To make things even more complicated, the lines should appear in the order given by a sequence. Here is a minimalistic example of input data: <?xml version="1.0"?> <matrix> <row> <line nr="1">A1</line> <line nr="2">B1</line> </...

XPath result to PHP Object

Hi, I have an xml file which represents a number of objects for which I have a class in my application. For example, blogposts: <blogposts> <blogpost id="604"> <title>afdghadfh</title> <body>adfgadfgda</body> </blogpost> <blogpost id="605"> <title>dafghadh</title> <body>afadf</body> </blogpost> </blogposts> ...

xpath: get nodes that do not have an X ancestor

I want all nodes of an xml document that are not descendants of nodes X. (My actual problem is a little more complex, but I'm stuck with the "are not descendants" part right now). ...

Using xpath on PHP: how to select first child?

So I have a XML structure like this one: <layout> <pattern> ... </pattern> <row> ... </row> </layout> How can I select the first node of /layout/ by its index, using xpath? W3C says: There is a problem with this. The example above shows different results in IE and other browsers. IE5 and later has implem...

XPath element which contains an attribute and whose parent's parent contains another attribute

Hey everyone, This is my first post here and since I've seen many great answers I thought I'd give it a try. I'm trying to use XPath to obtain a specific element in an HTML document. Here is an example based off of the Google web page: <html> <head> <title>XPath Test</title> </head> <body> <form name='f'> <table> ...

Using XPath function fn:replace from XSLT

I'm trying to use XSLT to convert a simple XML schema to HTML and planned to use fn:replace to replace returns (\n) with <p>. However, I can't figure out how to use this function properly. A simplified version of the XSLT I'm using reads: <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org...

Selenium: how to find div with specific content?

I need to find a <div> with certain content and click it from Selenium, as so: <tr> <td>clickAndWait</td> <td>//div[@class='gwt-Label' ***WITH CONTENT='Logout'***]</td> <td>5000</td> </tr> Is there some way to do this? I don't want to use an absolute xpath. ...

Do XPath on a Node with Java

I have someNode and I'd like to do XPath on it like this: XPath xpath = XPathFactory.newInstance().newXPath(); XPathExpression expr = xpath.compile("//name"); Object result = expr.evaluate(SOMETHING_ELSE, XPathConstants.NODE); How can I turn someNode to SOMETHING_ELSE and do my XPath? ...

XPath 2.0 : Open implementations

I find it very difficult to find an XPath 2.0 implementation outside of Saxon. What are the XPath 2.0 options in other languages ? Note : This blog post made an interesting summary of the situation in 2007. ...

XPath Query using contains with multiple values

I need an XPath that will elect all parent nodes a child with anattribute that constains at least one of a list of values. Example XML <mynodes> <theParentNode> <theChildNode name="one two" /> </theParentNode> <theParentNode> <theChildNode name="one all" /> </theParentNode> <theParentNode> <theChildNode name="...

Selecting the next link using XPath

I have to write an XPath expression to get the href attribute of the anchor tag in the html bellow that comes right after the one that is marked as "current-page" (in the example #notimportant/2). <dd> <a href="#notimportant/1" class="current-page">1</a> <a href="#notimportant/2">2</a> <a href="#notimportant/3">3</a> <a ...