xpath

XPath to get one level of childnodes

Using DOMXPath::query is it possible to get just one level deep of childNodes? For example if I had a document like: <div> <span> <cite> </cite> </span> <span> <cite> </cite> </span> </div> I would want the NodeList to contain just the spans and not the cites. Should also mention that ...

Finding an elements XPath using IE Developer tool

Hello, Is there a way to find an element's XPath using IE Developer Tool? Thanks, Teddy ...

Best XPath tools

What tools are you guys using for XPath and why? Right now I'm using SketchPath because its totally awesome, but its a windows app that needs to be installed WhiteBeam online XPath test bedbecause you can test expressions from the website SketchPath seems to stand out the most to me because it actually helps you create the xpath and ...

Use XPath to select an element that doesn't have an img tag as a child.

Is it possible to select an h1 tag that does not contain any img tags with a single line XPath expression? If so, what is it? ...

Order nodes by most images?

This might sound a bit complicated, but what I want to do is find all <a>s that contain <img>s such that the images that are in the same node with the greatest number of other images are chosen first. For example, if my page looks like this: If the blue squares are <div>s and the pink squares are <img>s then the middle div contains t...

XPath selection by innertext

I'm trying to extract an element with a particular innertext from a parsed XML document. I know that I can select an element that has a child with a particular innertext using //myparent[mychild='foo'], but I actually just want to select the "mychild" element in this example. <myparent> <mychild> foo </mychild> </myparent> What would...

xpath: Is there a way to get all the children's text in xpath

I'm using the xpath engine on Firefox. I have html: <span> <b>prefix one</b> not bold part </span> <span> prefix two not bold part </span> I want all the spans that have child text that start with "prefix one". I tried the xpath: //span[starts-with(child::text(), "prefix one")] but this doesn't work because the b tag is inte...

Using XPATH, how do I select multiple elements while retaining the path

Assuming I have a XML like so: <a> <b> <i>data</i> <ii>data</ii> <iii>data</iii> </b> <b> <i>data<i> <ii>data<ii> <iii>data</iii> </b> </a> Using XPath, how would I select the above XML to create a structure like so: <b> <i>data</i> <ii>data</ii> </b> <b> <i>data<i> <ii>data<ii> ...

XPath to match only directly following siblings

I have the following kind of HTML. The content is grouped by the <div "id=foo"> and <div "id=foo1"> elements, with <div "style=padding…"> in-between. I'm trying to figure out how to craft an XPath expression that will allow me to trigger off the "id=foo" to return the sibling <div>s with "style=padding…" Getting the <div id="foo"> is t...

What xml parser should I use?

I have a somewhat large file (~500KiB) with a lot of small elements (~3000). I want to pick one element out of this and parse it to a java class. Attributes Simplified <xml> <attributes> <attribute> <id>4</id> <name>Test</id> </attribute> <attribute> <id>5</id> <name>Test2</name> </attribute> <!--3000...

XPath 2.0 Libraries for .Net

Which XPath 2.0 libraries (apart from saxon) are available, preferably for .Net? ...

extracting content of content attribute in meta tag of a website given a specified value for the name attribute with nokogiri in ruby?

My first question here, would be awesome to find an answer. I am new to using nokogiri. Here is my problem. I have something like this in the HTML head on a target site (here a techcrunch post): <meta content="During my time at TechCrunch I've seen thousands of startups and written about hundreds of them. I sure as hell don't know all ...

selenium: Is it possible to use the regexp in selenium locators

I want to get the xpath count of all the divs/links/.. that have text matching some regular expression. For example: <span> day 2 night </span> <span> day 4 night </span> <span> day 17 night</span> I would like to be able to call: sel.get_xpath_count('regexp:day \d night') and have it return 2. (This is a simple example of course, ...

Does this xpath look correct?

page.getByXPath("//*[@href='http://www.example.com/index.do/abc/1_*'"); Do I need to escape any characters? I am trying to get all ahref links on the page that have the pattern of: http://www.example.com/index.do/abc/1_ so these should all be retrieved: http://www.example.com/index.do/abc/1_asdf-asdfasdf http://www.example.com/ind...

Question on xpath

Following Question: <div id="id-74385" class="guest clearfix" style="z-index: 999;"> Given above, If I want a xpath with checks both id and class, can we do it w/ 'and' condition LIKE: //div[@id='id-74385'] and div[@class='guest clearfix'] Is this correct way? My execution fails here... Please help! ...

Error when merging two XML documents using XPath & DOMDocument ...

Hi, everyone. About a year ago I wrote a jQuery-inspired library which allowed you to manipulate the DOM using PHP's XPath and DOMDocument. I recently wanted to clean it up and post it as an open source project. I've been spending the past few days making improvements and implementing some more of PHP's native OO features. Anyhow, I th...

XPath where the requirements apply to deeper nodes than the ones in resulting set

In my answer to another post in SO (here: http://stackoverflow.com/questions/1948552/sharepoint-2007-how-to-check-if-a-folder-exists-in-a-document-library/2005855#2005855) I had to parse an XML document with structure: D:multistatus |--D:response |----D:propstat |-------D:prop |----------D:displayname |----------D:isFolder Is it possi...

Selecting a certain row from a dataset

Hi, I have a Dataset and want to display the containing rows in a WPF-Contorl. The problem is, that the control is sort of a circuit diagram. Thus I created a template to show the values and placed multiple instances of it in my circuit control. Currently the XAML-code in the circuit looks like this: <Label Content="{Binding Path=.[0]}"...

xpath to get rows inside a table

I have a html table like: <table ..... class="cars"> <tr class="item-odd"> ... </tr> <tr class="item-even"> </tr> </table> How could I get the table rows using xpath? //tr[contains(@class, ???) can I use OR in there somehow to say item-odd|item-even ...

Could the value of an html anchor tag be fetched using xpath?

If I have HTML that looks like: <td class="blah">&nbs;<a href="http://....."&gt;????&lt;/a&gt;&amp;nbsp;&lt;/td&gt; Could I get the ???? value using xpath? What would it look like? ...