xpath

Is there a library to get/set property from a string (xpath or Property Path)

I am looking for a way to use a string instance path or xpath expression to get/set property values very similar to what wpf does with it's data binding. Do you know of a library for this? I found ObjectXpathNavigator but I am not sure if there is something a little more active out there. Get("Person.FirstName"); Set( "Person/LastName...

XPath, Selenium: Element is found in XPath checker but not in Selenium!?

I have the following XPath: //div[contains(@id, 'box')]/div/h4/small/a[contains(@href, 'google')]/@href When I try out this XPath in XPath Checker (Firefox extension), it works perfectly all the time. But when I do the following in Selenium: System.out.println(selenium.getAttribute("//div[contains(@id, 'box')]/div/h4/small/a[contains...

Regex: Does an XPATH string point to an attribute?

Here's what I'm using: ".+/@[^/]+$". Can you think of a reason why this might not work? ...

Best way to implement an xpath-like configuration system

I'm trying to come up with the best way to handle configuration in an application. At first i just used SimpleXML and put the code in a singleton. I've decided to try to create a way to query the configuration with something like $config->getConfig('/module/name'); Do you have to use xpath to do this or is there any other method that ...

How to access a xml node with attributes and namespace using selectsinglenode()

I have this document where i want to get to the value in "x_server_response/retrieve_resources_by_category_response/source_full_info/record/ datafield[@tag='520']/subfield[@code='a']" But i just can't! Why? i suspect that this has something to do with the namespace daclaration at the record node. But i can not figure out how to do it. ...

Powershell XPath selection

Hi, I'm looking to use powershell to alter xml. I haven't been able with powershell to copy xml using the xpath. I can load the xml with the following: $doc = new-object "System.Xml.XmlDocument" $doc.Load("XmlPath.xml") but after I get the XML I can't figure out how to list the xml with an xpath and create another xml file with wha...

Is binding from two datasources possible?

Hello, I would like to know, if it is possible to do something like this in XAML. <Binding Source="{StaticResource baseData}" XPath="/baseData/nodes[@value={StaticResource actualData},XPath=/actual/node}]/text" /> The code-example ist not possible. But how could I select a node from baseData with the value of the node /act...

XPath: what can be selected?

Am I correct in thinking an XPath expression can only point to/select either an element or an element attribute? ...

Lxml html xpath context

Hello, I'm using lxml to parse a HTML file and I'd like to know how can I set the context of xpath search. What I mean I that I have a node element and want to make xpath search only inside this node as if it was the root one. For example, I have a form node and xpath search //input return only inputs of the given form as opposed to all ...

Is it bad practice to use string literals in xpath expressions?

I currently use string literals in my xpath expressions. For example: paragraphList = root.SelectNodes("paragraph"); I know you should generally avoid using literal values, but I figure this is safe, since the names of your xml nodes will rarely change. Is this bad practice, or am I same? ...

Howto prevent XPath from return all if empty compare-variable?

Hello, i have this construct to questionate my xml-document with a binding in xaml. XPath="/doc/B/lists/entry[@value=(/doc/A/selectedValue)]" If the path /doc/A/selectedValue is empty or did not exist all nodes of /doc/B/list/entry are returned. Is there a way to define that nothing should be returned in the case that /doc/A/selected...

PHP SimpleXML XPath contains() to find other elements referenced by this element

Hi Guys ang Gals, I'm being given XML in the following format, and am parsing it with PHP's SimpleXML. <?xml version="1.0" encoding="UTF-8"?> <ManageMyBooking> <BookingInfo> <PartyDetails> <Passenger> <PaxNo>1</PaxNo> <Title>Mrs</Title> <Surname>Murphy</Surname> ...

Filter SQL queries on the XML column using XPath/XQuery

I'm having a table with one XML column. I'd like to filter out the rows where a specific attribute in the XML match a string, essentially doing a WHERE or HAVING. The table looks something like this | id | xml | And the XML something similar to <xml> <info name="Foo"> <data .../> </info> <xml> I want to get all ids where ...

XPath: Is there a way to set a default namespace for queries?

Is there a way to set Java's XPath to have a default namespace prefix for expressons? For example, instead of: /html:html/html:head/html:title/text()", the query could be: /html/head/title/text() While using the namespace prefix works, there has to be a more elegant way. Sample code snippet of what I'm doing now: Node node = ... // DO...

How to read/write nodes and child nodes from xml file in c# maybe using xpath?

Hello, Maybe somebody could help me. I need a two methods. The first should open a xml file and get all nodes with the given parameter ie.: XML file (file.xml): <Menu id="1" Name="myMenu"> <MenuItem Header="Header 1" Name="header1" /> <MenuItem Header="Header 2" Name="header2"> <MenuItem Header="subHeader 2.1" Name="header2_...

Why doesn't Nokogiri xpath like xmlns declarations

I'm using Nokogiri::XML to parse responses from Amazon SimpleDB. The response is something like: <SelectResponse xmlns="http://sdb.amazonaws.com/doc/2007-11-07/"&gt; <SelectResult> <Item> <Attribute><Name>Foo</Name><Value>42</Value></Attribute> <Attribute><Name>Bar</Name><Value>XYZ</Value></Attribute> </Item> </S...

Using selenium in order to read emails on gmail

I'm using selenium-rc and I'm trying to click on a specific email on gmail in order to get into the email page. More specifically: on the gmail inbox, click on a email with a specific subject. I can't find the correct xpath (none of the tags in the email part are links). Ideas? ...

XSLT: What this exactly do: test="element[@attribute]"

what this exactly do : <xsl:if test="./employee/first-name[@id='14']" > I mean, when will this case be true, if ./employee/first-name[@id] != null or "", or what exactly? EDIT: I have edited the statement above, so it test if element first-name with id=14 have a body or its body contains a data or return true if first-name event don...

Filtering a structure in XML by attribute

I have a nested simple XML structure that I load with PHP's simpleXML. Some elements of the structure contain "context" attributes. <tab context="new_item, edit_item"> <input type="text" context="new_item"> <input type="readonly" context="edit_item"> <tab context="new_item"> ... </tab> </tab> After loading, I need ...

C# XML adding/copying

Hi, With the following XML I am trying to copy and add to another XML but I haven't used the C# XML document objects before. So here is the XML <config> <configXML> <Connections> <Connection excyptedConnection="encrypted string"> </Connections> <configXML> </config> I want to be able to copy out the Conne...