xpath

What is the Flex/AS3/E4X equivalent of this xpath query?

Given this document: <doc> <element> <list> <key attr='val'/> </list> </element> <element> <list> <key attr='other'/> </list> </element> <element> <list/> </element> </doc> I want an e4x equivalent of the xpath //element[list/key/@attr="val"]. Is i...

Does Javascript have internal knowledge of the raw source code of a given document?

<html> <head> <script> remove_line(11); // This should remove the line 11 from source code, // eliminating the unordered list element. </script> </head> <body> <p>Some text</p> <ul><li>Some list item</li></ul> <a>Some link</a> </body> </html> I am totally aware that this code hurts your eyes. However,...

What is the best way to uniquely identify a DOM node ?

What is a way to uniquely identify all DOM nodes in an HTML document. To illustrate what I mean, here is a (fictional) example: Script X randomly selects a DOM node from document.html. Script X needs to tell script Y which DOM node it has chosen. How does script X uniquely identify the DOM node it has chosen so that script Y knows exac...

XSLT: Using an assembly for scripting in a referenced XSL template

There are two XSL files. One includes another using an <xsl:include>. The main template desides which actual templates to call depending on node values, and included templates contain actual transformation rules. Nothing special here. But included file has a script block: <msxsl:script language="VB" implements-prefix="user"> <msx...

html 4.0 entities in XPATH queries

I don't know exactly why the xpath expression: //h3[text()='Foo &rsaquo; Bar'] doesn't match: <h3>Foo &rsaquo; Bar</h3> Does that seem right? How do I query for that markup? ...

jQuery Xpath selector to select an element which id contains 'sometext'

I have a listbox element in aspx page which id is attributesList. I want to select this element to track its change event, but i cant directly select its id because asp.net changes its id on runtime. its id, attributesList changes into ctl00_adminPlaceHolder_attributesList. so what i want to do is to use a "contains" xpath expression ...

XPath for XML with namespace

Hi, I have an xml with various namespaces that i would like to query using .SelectNodes(string xPath) The problem that i notice is that the xPath query return nothing as long as i have all those namespaces around. is there anyway to tell XmlDocument.SelectNodes to ignore those namespaces and just get me the correct elements (the ele...

What's wrong with this findnodes statement in my Perl's script?

I have a simple xml file that looks like this: <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> <microplateDoc xmlns="http://moleculardevices.com/microplateML"&gt; <camelids> <species name="Camelus bactrianus"> <common-name>Bactrian Camel</common-name> <physical-characteristics> <mass>450 to 500 kg.</mass> ...

Why can't I access elements inside an XML file with XPath in XML::LibXML?

I have an XML file, part of which looks like this: <wave waveID="1"> <well wellID="1" wellName="A1"> <oneDataSet> <rawData>0.1123975676</rawData> </oneDataSet> </well> ... more wellID's and rawData continues here... I am trying to parse the file with Perl's libXML and output the wellName and the rawDat...

how to use xpath? (nokogiri)

I have not found any documentation nor tutorial for that. Does anything like that exist? doc.xpath('//table/tbody[@id="threadbits_forum_251"]/tr') the code above will get me any table, anywhere, that has a tbody child with the attribute id equal to threadbits_forum_251. But why does it start with double //? why there is /tr at the e...

What is the correct Xpath query to access an element in Perl's XML::LibXML?

I'm trying to access an element called raw data, inside some <rawData>data is here</rawData> tags. However this XPath query with Perl's XML::LibXML is not working: foreach my $m ($xc->findnodes(q<//ns:wave[@waveID='1']/ns:well/oneDataSet/rawData>)) { print $m->textContent, "\n"; } but a similar query to get an attribute @wellName...

Trim function in XPath 1.0?

Is there a trim function in XPath 1.0, that can be used like this: .//a[trim(.) = @href)] ? ...

Will XPath 2.0 and/or XSLT 2.0 be implemented in PHP?

The question was asked but deleted by the asker before it received an answer. Because I believe the question is sound and legitimate and serves a purpose, I'm asking it again and provide the answer I already wrote for the original q. Will XPath 2.0 and/or XSLT 2.0 be implemented in PHP some day or are there any plans? ...

Xpath for choosing next sibling

I have piece of HTML like this: <dt>name</dt> <dd>value</dd> <dt>name2</dt> <dd>value2</dd> I want to find all places, when the structure is incorrect, meaning there os no dd tag after dt tag. I tried this: //dt/following-sibling::dt but this doesn't work. Any suggestions? ...

What's the difference between XSL Pattern and XPath in syntax?

I'm updating codes to use MSXML6.0 from MSXML3.0. However, I noticed that, for MSXML3.0, the default "SelectionLanguage" is "XSL Pattern", while MSXML6.0 only support XPath. I have concerns that this change would introduce differences in the query syntax. Can somebody list the difference of syntax between these two syntax? ...

why wouldn't this XPath example work?

I am trying to locate the first <th> element under a <table> element. The table element is tagged with a particular id, and is locatable when I only look as far as that tag. But when I try to go a little further down and search using the XPath below, it returns a null element. The '/th[0]' is to say: return the first <th> element, under...

Parsing iCalendar data with XPath/XSLT

I am working with a XML driven CMS, and before I run off and either write or implement a module that parses the iCal format, I was wondering if there was any way to parse it using just XSLT or ideally just an XPath expression, as this is a built in function of the CMS. ...

adding php variable into Xpath

Hi , i just need to add in a variable into the xpath my code is as followed $target = $xml->xpath('//gig[@id=$1]'); but I need it too but something like $target = $xml->xpath("//gig[@id=$" $change . "]"); Is this possible ? If so could some one help ? ...

XPath union operator and context

I have following: <xsl:for-each select="/ROOT_NODE/NODE_1/NODE_11/LOCALE[CO &gt;= 8] | NODE_2/NODE_22/OCA"> </xsl:for-each> two questions: I need to confirm what is the context for NODE_2 in relation to /ROOT_NODE tree above. I'm thinking /ROOT_NODE/NODE_1/NODE_11/NODE_2. Is this correct? What will be the context node insi...

how to use nokogiri methods .xpath & .at_xpath

I'm learning how to use nokogiri and few questions came to me based on the code below require 'rubygems' require 'mechanize' post_agent = WWW::Mechanize.new post_page = post_agent.get('http://www.vbulletin.org/forum/showthread.php?t=230708') puts "\nabsolute path with tbody gives nil" puts post_page.parser.xpath('/html/body/div/div/d...