xpath

Python XML and XPath to sort things out

Let's say I have an XML as follows. <a> <b> <c>A</c> </b> <bb> <c>B</c> </bb> <c> X </c> </a> I need to parse this XML into dictionary X for a/b/c and a/b'/c, but dictionary Y for a/c. dictionary X X[a_b_c] = A X[a_bb_c] = B dictionary T T[a_c] = X Q : I'd like to make a mapping file for this in XML file using XPath. ...

Highest sum of values per group in XSL

There is probably a very easy solution for this problem. I could easily do this in C#-LINQ. Unfortunately, I'm not so experienced with XPath and XSL. I have an input XML file that contains the following structure: <group> <val>1</val> <val>3</val> <val>1</val> </group> <group> <val>3</val> <val>2</val> <val>2</v...

selenium XPATH matches method

I have problems running the matches XPATH method: @Test(groups = "regression") @Parameters( { "baseUri", "locale" }) public void testShopping(String baseUri, String locale) throws Exception{ session().allowNativeXpath("false"); String shoppingLink = session().getAttribute("//div[@id='footernav_links']//a[matches(@href,'.*shoppi...

Combining the use of preceding and following sibling in the same xpath query

Hi I have a quite simple problem but i can't seem to resolve it. Let's say i have the following code: <a> <b property="p1">zyx</b> <b>wvu</b> <b>tsr</b> <b property="p2">qpo</b> <b>qcs</b> </a> I want to select the nodes between the b node who has a property="p1" and the b node who has property="p2". I can do eith...

WPF, using XPath in XAML with XmlDataProvider to select nodes based on selected value in ComboBox

This question ties to my previous question but is more specific. Say I have two ComboBoxes, one populated with product names, the other empty. When a product is chosen, I want the second ComboBox to be filled with data related to that product. I have XML like the following: <Products> <Product name="MyProduct1"> <Componen...

Javascript / XPath error.

I was experimenting around with XPath, basically I'm trying to load a HTML page using XMLHttpRequest and select an element inside it from its XPath. Here's my code (Greasemonkey/Js): GM_xmlhttpRequest({ method: 'GET', url: url, headers: { 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey', 'Accept': 'application/atom+xml,app...

replace comma separated text with <br/> tag using xpath

Hi, I have a xml structure with a tag with text like 1.1, 2.2, 3.3 How can write an XPath to get the output to print the number one by one in each line like 1.1 in first line and 2.2 in next line and so on. The XPath logic should be something to replace the ',' with and get the above output. I am using XSLT 1.0. Please suggest ...

Concatenate multiple attribute values

Giving this kind of XML file : <data> <row val="3"/> <row val="7"/> <row val="2"/> <row val="4"/> <row val="3"/> </data> I need to retrieve the string '3;7;2;4;3' using XPath 1.0 so that I can create dynamic links for the Google Chart service in my XForms application. How can I do that ? Is it possible ? ...

Nothing returned for element name (XSL/XPath)

Hi! I have code that I expect to return the element name, but nothing is returned. The following code is from an XSL doc that generates another XSL doc.. where $expression is a variable that dynamically created an XPath expression. <xsl:template match="/"> ... <xslt:template match="{$expression}"> <elem key="{name()}">...

Help accessing xml attribute in php

Hi, I'm new to php and coding in general. I'm trying to parse xml from a remote device and access specific value data. I would like to display group 9 probe 1 value for example and I cannot get it to work. Any tips? Here is the xml: <?xml version="1.0" encoding="ISO-8859-1" ?> - <Device id="S10011" hb="1935"> <Group id="1" /> ...

using conditions in XPath expressions

Hi, I need to parse through an XML document in the database and search for a given expression in it. Then, I must return a String value if the given expression is present in the XML else I need to parse through the next expression and return another String value and so on. I achieved this by using the following code: // An xml docume...

XPath expression - help needed

Hello, I have sample XML like this: <users> <user name="user1"> <roles separator=",">ADM,USER</roles> </user> <user name="user2"> <roles separator=",">ADM,GUEST</roles> </user> <user name="user3"> <roles separator=",">READER,GUEST</roles> </user> </users> Is there any way to get all us...

What's the right test case to find which method call is faster between execute and getElementsByTagName?

What's the right test case to find which method call is faster between XPathExpression.execute("child::") and Element.getElementsByTagName("")? Via DOM search: NodeList nl = ((Element)this.currentNode).getElementsByTagName("*"); or via XPath: public static final <T> T xpath(QName qType, Node n, String exp) { try { XPathE...

I'm trying to extract each a href link on an html page for evaluation w/ nokogiri and xpath

I'm trying to extract each a href link on an html page for evaluation w/ nokogiri and xpath. What I have so far seems to be pulling the page titles out only. I'm not interested in the link title, but rather just the URL that is being pointed to. Here's what I have: doc = Nokogiri::HTML(open("http://www.cnn.com")) doc.xpath('//a').each...

using xpath to tell selenium where to click?

I'm new to all of this but I've learned a few things about python not long time ago, could you help me specify the correct the XPath for selenium to click? I've tried this way, but didn't work, obviously :( self.selenium.click("xpath=//html/body/div/div/div/div[4]/ul/li[3]/a") If you're wandering where did i get that ugly XPath, it's...

Which is faster, XPath or Regexp?

I am making an add-on for firefox and it loads a html page using ajax (add-on has it's XUL panel). Now at this point, i did not search for a ways of creating a document object and placing the ajax request contents into it and then using xPath to find what i need. Instead i am loading the contents and parsing it as text with regular expr...

WPF, display attribute value in TreeView instead of node name

If I have the following data template for a TreeView, what do I need to change so that each TreeViewItem shows the value of the name attribute on each XML node, instead of the node name? <HierarchicalDataTemplate x:Key="NodeTemplate"> <TextBlock x:Name="tb"/> <HierarchicalDataTemplate.ItemsSource> <Binding XPath="child::...

How to create XPCNativeWrapper for HTMLDocument

Hi, I am having troubles with making my Firefox extension use xPath on a page loaded via AJAX inside my extension window. Here https://developer.mozilla.org/en/DOM/document.evaluate it says that evaluate can be used with HTML or XML documents to evaluate xPath expression. So, i created a HTMLDocument object, assigned the AJAX response ...

XPath Node to String

How can I select the string contents of the following nodes: <span class="url"> word <b class=" ">test</b> </span> <span class="url"> word <b class=" ">test2</b> more words </span> I have tried a few things //span/text() Doesn't get the bold tag //span/string(.) is invalid string(//span) only selects 1 node I am using ...

Limiting string length in XSLT

I have node set with header, leading, body text etc... I want to make an excerpt and show only the first 70 characters of the leading. Is there a way to do this in XSLT? ...