xpath

In XSLT 1.0, how can I access attributes of a particular XML element when it is one of multiple elements with the same name?

I blame the Google Search Appliance for making me ask this question. Here is a snippet of the XML returned by the Appliance: <GSP VER="3.2"> <TM>0.073846</TM> <Q>test</Q> <PARAM name="entqr" value="0" original_value="0"/> <PARAM name="access" value="p" original_value="p"/> <PARAM name="output" value="xml_no_dtd" original_value="xml_no_...

Finding table values in watij using xpath

Hi, I am using watij to automate my UI testing. I have many tables in a webpage. I need to find a table which has a width 95%. It contains many rows. I have to find each row with different text say "running first UI test on local" as below adn need to get the td value "Complete". I am not ble to get the value but I get the watij address...

Better usage or alternative for starts-with in xpath.

I'm having a problem with a xsl transformation on a extended xml JUnit report file. I've extended the file as follows: <testcase classname="net.luminis.osgitest.test.adhoc.AdHocTest" name="testGetExportedPackagesByPackage" osgi-vendor-name="felix/1.8.0" time="3.212"> <osgi-specs> <osgi-spec version="4.1"> <sections> <section...

Asserting the background image of a page with selenium

Hey, I have an app in which the user can change the background image of their profile page. Therefore, I wasnt to assert that, when the user changes the image, the image actually changes. I can't for the life of me figure out a css selector or xpath to do the job. This is the HTML I have: <body style="background:#FFFFFF url(/uploads/i...

XML parsing with C#, XPath

Mine is a general question on XML parsing practices. Lets say we have an XML document, and we use XPath to get some node from that document: XMLNode node1=XMLDoc.SelectSingleNode("/SomeNode/SomeOtherNode"); Now n contains the data of SomeOtherNode. Intuitively I'd expect the following line of code: XMLNode node2=XMLDoc.SelectSingleN...

xpath query assistance

I have the following Xml structure; Payment/Line which has amongst its element a IsFeePayment and a IsServiceProduct elements of type bool. <Payment> <Line> <IsFeePayment>true</IsFeePayment> <ISServiceProduct>true</IsServiceProduct> </Line> </Payment> i want an xpath statement that returns 'true' when both of t...

Can I link maxOccurs in my schema to a value of another attribute in the target xml file?

I'm defining an xml schema for a file that looks something like this: <data> <config><segmentcount value="10"/></config> <foos> <foo> <segments> <segment data="X"/> <segment data="X"/> <segment data="X"/> <segment data="X"/> <segm...

Why my XPath request to XML file on web doesn't work?

There is an XML file with exchange rates http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml: <gesmes:Envelope> <gesmes:subject>Reference rates</gesmes:subject> <gesmes:Sender> <gesmes:name>European Central Bank</gesmes:name> </gesmes:Sender> <Cube> <Cube time="2009-11-26"> <Cube currency="USD" rate="1.507...

Need some help with XPath expression. One works, the other doesn't...

I'm using the COBRA HTMLParser but haven't had luck parsing one particular tag. Here's the source: <li id="eta" class="hentry"> <span class="body"> <span class="actions"> </span> <span class="content"> </span> <span class="meta entry">Content here </span> <span class="meta entry stub">Content here <span...

Any good Java HTML parsers?

I was using Cobra until now because of how easy it was but unfortunately it had some problem with a few test cases. Does anyone suggest a tried-and-tested library? I've tried Cobra's built in one and HTMLCleaner without any luck. ...

Xpath query exclude ancestors of a particular namespace

The following xpath query gets nodes except where the ancestor is a particular type: (/def:Image|…|//def:TextBox)[not(ancestor::clpm:EditableText)] However, I want to be able to exclude all nodes that have an ancestor that is in the clpm namespace. Can't work it out guys, any ideas? Thanks ...

How to avoid a SAXParseException using Xerces when HTML file includes mdash?

I am using the Xerces implementation within JDK6 to perform XPath queries on an HTML 4.0 transitional document. With the following code: XPath newXPath = XPathFactory.newInstance().newXPath(); XPathExpression xpathExpr = newXPath.compile(expression); Object xPathResult = xpathExpr.evaluate(inputSource, XPathConstants.NODESET); Where...

How can I translate this XPath expression to BeautifulSoup?

In answer to a previous question, several people suggested that I use BeautifulSoup for my project. I've been struggling with their documentation and I just cannot parse it. Can somebody point me to the section where I should be able to translate this expression to a BeautifulSoup expression? hxs.select('//td[@class="altRow"][2]/a/@href...

Problem using ancestor axis in an XPath predicate

Using this source document: <?xml version="1.0" encoding="UTF-8"?> <Root> <Element1 id="UniqueId1"> <SubElement1/> <SubElement2> <LeafElement1/> <LeafElement1/> </SubElement2> </Element1> <Element2 id="UniqueId2" AttributeToCheck="true"> <SubElement1> <LeafElement1/> <LeafElement1/> </Su...

XPath question multiple selects

var assets1 = data.SelectNodes("//asset[@id]=" + oldBinaryAssetId); var assets2 = data.SelectNodes("//Asset[@id]=" + oldBinaryAssetId); Is it possible to make 1 xpath query of the two above? ...

Get a specific number of results from an XmlDocument XPath query

I'm querying a Twitter RSS feed and supplying the results into a Repeater for display. I'd like to only get the first 5 results of the XPath query. Is there a way to do that in the XPath syntax or do I have to loop over the resulting XmlNodeList to pull out the first 5? XmlDocument doc = new XmlDocument(); XmlTextReader reader = new Xml...

how to get the normalize-space() xpath function to work?

I am currently trying the following xpath //tr[normalize-space(td/text())='User Name'] to get all the tr that contains a td that contain 'User Name' or 'User Name' or ' User Name ' but its not working and I don't know what is wrong with the query :( the data i want to find is in the following format <tr><td>User Name</td></tr> ...

How to trim whitespace from a data-bound XML element in WPF using XPath?

How can the whitespace at the start and end of the content of an XML element be removed when binding to the element using XPath in WPF? ...

Bind arguments to button in Repeater

I have a button in a repeater that needs to bind XPath data to an argument <asp:Repeater ID="DVDRepeater" runat="server" DataSourceID="XmlDataSource1"> <ItemTemplate> <img src='images/products/<%#XPath("image")%>' title='<%#XPath("@name")%>' alt='<%#XPath("@name")%>' style="flo...

[XPath] Get the path of an element

Hi folks, is there a XPath function, which returns the absolute path of an element, so I can use it in sth. like: <xsl:if test="path() = /root/parent/child"> ... </xsl:if> Thanks. ...