xpath

How to calculate the XPath position of an element using Javascript?

Let's say I have a large HTML file with different kinds of tags, similar to the StackOverflow one you're looking at right now. Now let's say you click an element on the page, what would the Javascript function look like that calculates the most basic XPath that refers to that specific element? I know there are an infinite ways of refer...

XPath-Problems when selecting a attribute of a XML-Tag

Hi guys, I could use a little help with an XPath-Expression. check the code below; how do I select the attribute "idc" at the shown point? <!-- XML-Code --> <pictGaleList> <item> </item> <dateItem> <ImageDate idc="20"> 20/04/2010 </ImageDate> </dateItem> </pictGaleList> <!-- XSLT --> <xsl...

How do I find a XML node by path in Linq-to-XML

If I get the path to a specific node as a string can I somehow easily find said node by using Linq/Method of the XElement ( or XDocument ). There are so many different types of XML objects it would also be nice if as a added bonus you could point me to a guide on why/how to use different types. EDIT: Ok after being pointed towards XPat...

Need help fixing XSLT document

Hi! I have two problems with the below code that I need help fixing: 1) It doesn't include the root node when returning results from the XPath expression. (I've tried a couple things, but it messes up the results even more..) 2) I need help fixing the formatting of the results. I need the same nodes with the same attributes to be list...

Find maximum value of all child elements and get it’s parent element in xslt

This question is related to this post http://stackoverflow.com/questions/3461728/find-maximum-value-of-all-child-elements-and-get-its-parent-element-in-xslt. I asked my question incorrectly. Actually I need output little different. I need to match site node id with worksite node and find out the person who worked more hours for that site...

XSLT: Retrieve element that contains a particular string, or first element if absent

I have an XML list of "devices". <devices> <device>NOKIA-43</device> <device>HTC-7</device> <device>SAMSUNG-376</device> <devices> Using XSLT, I want to retrieve the first "HTC*" device if there is one, or the first device if there are no HTC devices. What XSLT code would do this? Thank you! ...

How do you use XPath to confirm whether a Form element is found in the passed in markup for loadXML?

Set objNoFormCheckXMLDOM = CreateObject("Microsoft.XMLDOM") objNoFormCheckXMLDOM.async = "false" objNoFormCheckXMLDOM.setProperty "SelectionLanguage", "XPath" objNoFormCheckXMLDOM.LoadXML(strHtmlResponse) Set nlForms = objNoFormCheckXMLDOM.selectNodes("form") I have the above VBScript in a function. strHtmlResponse contains t...

Manipulating list from lxml xpath queries

Today I tried lxml as I got very nasty html output from particular web service, and I didn't want to go with re module, just for change and to learn something new. And I did, browsing http://codespeak.net/lxml/ and http://stackoverflow.com in parallel I won't try to explain above html template, but just for overview it's full of deliber...

Convert dateTime to unix epoch in xslt

Hi. I have a dateTime variable, and I want to convert it to a decimal value of epoch. How can this be done? I tried using: seconds-from-duration($time, xs:dateTime('1970-01-01T00:00:00')) but it just returns 0. Please advice. Thanks. ...

problem getting xpath function ends-with() to work while contains() works fine.

hi i am trying to get the tags that have an attribute that end with a certain id. like <span id="ctl00_ContentPlaceHolder1_Country"> i want to get the spans that have the id ends with 'Country' i try the following xpath //span[ends-with(@id,'Country')] but i get the following exception "Namespace Manager or XsltContext needed. This query...

LXml Xpath processing of multi-line field

I'm doing some scraping of a page and I'm fine with getting most fields, but having some problems with the address. <address> 56 South Ave <br> Miami, FL 33131 <br> </address> address = myWebPage.xpath("//div[contains(@class,'rightcol')]//address") I can get the first line, 56 South Avenue, using the above code. But I can't...

Simplexml xpath to attribute value and and child node values in one query

example XML: <users> <user id="fakeuserid"> <password>fakeuserpassword</password> <username>fakeusername</username> </user> <user id="anotherfakeuserid"> <password>anotherfakeuserpassword</password> <username>anotherfakeusername</username> </user> </users> I would like to be able to access the id attrib...

Can't access sub nodes with XPath expression

Trying to figure out XPath and I have successfully create an XPathExpression that lets me grab the events, but any nested sub groups seem to be unavailable to the query, I can get all the children on the Events group, but the LocationName field I can not access. I am trying to figure out how to get the LocationName child into my query ...

XPath Perl get attribute value

I'm trying to get XPath to return an attribute value yet first search for the tag's contents, i.e. if I have <select name="xxx"> <option=bla>123</option> <option=blubb>456</option> </select> I want to say, "search for the option tag containing 456 within a certain select tag with name "xxx". I do this: my $xp = XML::XPathEngine-...

Selecting nodes possessing all/any values in list

I'm looking to take a delimited list of category IDs provided in one element... <Categories>851|849</Categories> <MatchType>any</MatchType> ...and use them to style other elements... <Page CategoryIds="848|849|850|851">Page 1</Page> <Page CategoryIds="849|850|">Page 2</Page> <Page CategoryIds="848|850|">Page 3</Page> <Page CategoryId...

XPath choking on entities in Firefox / GreaseMonkey

Hi there. I am writing a fairly basic GreaseMonkey script that locates text in a specific element and then uses that text to do things later. The relevant bits of code are as follows: In the HTML there is a span with the class 'someclass', which contains a small string of text: <span class="someclass">some text</span> Then in the Jav...

Not IN equivalent in XPath expression

Hi, I am working on an XSL development and I am in need of knowing the NOT IN equivalent in XPATH. I am presenting the XML and XSL in the simplest format which would be understandable to all. <?xml-stylesheet type="text/xsl" href="XSL.xsl"?> <Message> <Customers> <Customer pin="06067">1</Customer> <Customer pin="060...

How to find Xpath ?

Hi, is there any easy way to find xpath ? <span class="r5">5</span><a href="http://google.com"&gt;Google&lt;/a&gt; what will be the xpath of r5 ? Thanks.. ...

Xpath equivalent to http://gskinner.com/RegExr/ for Regex?

I wonder if there is a Xpath equivalent to http://gskinner.com/RegExr/ for Regex? In this way you could just type an xpath query and it will show you what elements were selected. I haven't found anything as simple as http://gskinner.com/RegExr/ yet. ...

Xpath and HTML Cleaner problem, no data returned.

Hi, new to the community. been up all night trying to flesh out the underlying html reading system that's at the core of my app's functionally. I could really use a fresh pair of eyes on this one. Problem: While trying to return a string to be displayed on my app's home activity, I've run into an issue where I'm almost certain that th...