xpath

XPath search based on dynamic regular expressions

Hi I have an XML like the one below: <?xml version="1.0" encoding="UTF-8"?> <Configuration> <Destinations> <Destination name="DEST1" > <From>AMA*</From> </Destination> <Destination name="DEST2" > <From>AMAZON</From> </Destination> ...

XSLT - How to select XML Attribute by Attribute?

Hello, this is the structure of my source xml: <root> <DataSet Value="A"> <Data Value1="1" Value2="anythingA1" /> <Data Value1="2" Value2="anythingA2" /> <Data Value1="3" Value2="anythingA3" /> <Data Value1="4" Value2="anythingA4" /> <Data Value1="5" Value2="anythingA5" /> </DataSet> </root> from which I like to create some variables ...

Selecting attribute values with html Agility Pack

I'm trying to retrieve a specific image from a html document, using html agility pack and this xpath: //div[@id='topslot']/a/img/@src As far as I can see, it finds the src-attribute, but it returns the img-tag. Why is that? I would expect the InnerHtml/InnerText or something to be set, but both are empty strings. OuterHtml is set to ...

Default XML namespace, JDOM, and XPath

I want to use JDOM to read in an XML file, then use XPath to extract data from the JDOM Document. It creates the Document object fine, but when I use XPath to query the Document for a List of elements, I get nothing. My XML document has a default namespace defined in the root element. The funny thing is, when I remove the default name...

How to find out an element node with a empty string value in xsl

Hi, everyone: I am working on transforming a xml file from old version to new version. Here is the basic template which i am using: <xsl:template match="*"> <xsl:element name="{name(.)}" namespace="{namespace-uri(.)}"> <xsl:copy-of select="@*"></xsl:copy-of> <xsl:apply-templates></xsl:apply-templates> </xsl:element>...

When using XPath to find variable, taking only a piece of that variable

Hi, I am new to XPath. I am writing a code to grab all the 3 digit numbers from a page. They are not constant, varying between 105, 515, and 320. I want two be able to tokenize these numbers into two separate pieces... i would love to be able to grab the first digit in one X-path expression and the second two digits in a second X-...

XPath 1 query

Hi, I posted a similar question and I got a very useful reply. Now the question is a little different, so I post it. I specify it is an XPath 1 related question. This is the content of my XML file: <?xml version="1.0" encoding="ISO-8859-1"?> <mainNode> <subNode> <h hm="08:45"> <store id="1563">Open</store> </h> ...

PHP & xPath Question

I'm using PHP and xPath to crawl into a website I own (just crawl the html not going into the server) but I get this error: Catchable fatal error: Object of class DOMNodeList could not be converted to string in C:\wamp\www\crawler.php on line 46 I already tried echoing just that line to see what I was getting but I would just...

Is there any good XPath Library for Delphi 2007 or above?

I have created my own XPath library for Delphi 2006 and have used it since. It works fine but could have more performance, and I don’t really have the time to maintain it any more. What other library could I use? ...

Removing all \n\r characters from a node XSLT?

Hi wondered if you could help me please? I have node in xml that is as followed $LOG: 08880xbpnd $ fhdsafidsfsd df sd fsd f sd fsd I was wondering is there anyway to make all the text go on to one line so that it then can be passsed through to a javascript function? so it would turn out like this $LOG: 08880xbpnd $fhdsafidsfsddfsdf...

Is inheritance possible in JFlex?

I'm fairly new to JFlex and JSyntaxPane although I have managed to hack together a lexer for XPath. The problem I find myself in is that I'm working on a project that supports a subset of XPath with a few proprietary features. Nasty I know. If this were a regular Java problem I'd turn to inheritance but it doesn't seem possible to ach...

is there a way to combine xpath and regexp to extract parts of a node value?

this is what I want... Assuming I'm trying to get at the value of 'B' <tree> <nodea> <nodeb> A=foo; B=bar; C=goo; </nodeb> </nodea> </tree> the following is magical syntax which would make sense... I'm looking for something comparable that actually works :) string = "./nodea/nodeb/[ REGEX( 'B=(.*?);' ) ]/ $1" Is there anything lik...

Selenium: How do I execute an Xpath function or expression in my test?

Is there a way to execute some Xpath code in a Selenium test? I know you can execute javascript, but I'm looking for a way to execute some Xpath code beyond simply locating an element on the page. Anyone run into this? ...

Select an element that has another element anywhere inside

How do I select any node a that has node b anywhere inside it? Given the following three XML documents: <a> <b></b> </a> or <a> <c> <b></b> </c> </a> or <a/> I want the a element in the first two documents to be selected. Apparently, a[//b] is not a solution. ...

XPath SelectNodes in .NET

Document A B C /B /A E F C /c /F G C /C /G /E /Document If i load the above XML into an XmlDocument and do a SelectSingleNode on A using the XPath query //C XmlNode oNode = oDocument.SelectSingleNode("E"); XmlNodeList oNodeList = oNode.SelectNodes("//C"); why does it return nodes f...

Including an attribute of an unrelated element in an XPath

Hi, I have the following XML file: <phonebook> <departments> <department id="1" parent="" title="Rabit Hole" address="" email="" index=""/> <department id="2" parent="" title="Big Pond" address="" email="" index=""/> </departments> <employees> <employee id="1" fname="Daffy" lname="Duck" title="Admin" email="da...

XPath on an XML document with namespace

Bonjour tout le monde, I'm having this XML document with namespaces and I want to extract some nodes using XPath. Here's the document: <ArrayOfAnyType xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/"&gt; <anyType xsi:type="Document"> <Id>5</Id> <Ti...

XPath Node element indexing based on attribute

I am trying to build an Infopath form which populates fields with data back from a Sharepoint list. I set up a drop-down list box who's values get populated from a Sharepoint data source. That part works fine. Now I want other string fields to get automatically populated once the user selects one of the items from the list. So I set up ...

How do I retrieve element text inside CDATA markup via XPath?

Consider the following xml fragment: <Obj> <Name><![CDATA[SomeText]]></Name> </Obj> How do I retrieve the "SomeText" value via XPath? I'm using Nauman Leghari's (excellent) Visual XPath tool. /Obj/Name returns the element /Obj/Name/text() returns blank I don't think its a problem with the tool (I may be wrong) - I also read XP...

Xpath expression with multiple predicates

Hi, I am trying to build a complex xpath expression which will answer the following condition. From the XML data below, returns the User entity which: His loginname is "user1" His name is "User 1" He has 2 different profiles values which are "operator" and "admin" (I don't know the exact order ahead) <user> <login>user1</lo...