xpath

XSLT: pass value from one for-each match to the next

I'm using the following to match all <section>s with a revision attribute set. <section>can appear at many different levels of the document tree, always contained within <chapter>s. <xsl:for-each select="//section[@revision]"> <!-- Do one thing if this is the first section matched in this chapter --> <!-- Do somethi...

xpath not recognized in selenium, but is recognized in XPather

I have the following code in my script: System.out.println(selenium.getAttribute("xpath=//div[@class='guest clearfix'][1]/@id")); When I try to run the script, it says the element is not found. If I enter the xpath into XPather (addon for firefox) //div[@class='guest clearfix'][1]/@id, it will correctly give me the id. I am stumped ...

XSLT & Xpath syntax > how to refer to an element in an 'outer' scope

Hi, I have the following working 100% correctly. However to satisfy my curiosity... is there a way to achieve the same without declaring the currentID variable? Is there some way to reference it from within the Xpath "test" condition? The xpath query in the condition must refer to 2 @id attributes to see if they match. the 'current...

Sum contents of column based on a variable with XPath

Hi.. I'm a little bit of a rookie when it comes to XSLT and XPath, so I've run into this problem. I'm creating a simple table based on a view on the databse, which needs to sum some of the columns in the view. What I thourght i could do was add 'SUM_' as a prefix of all the coumns that i want to sum, and cut that tag off with a substring...

Xpath replace function, processing matches

I'm writing a function to "title case" strings e.g. "this is a title" to "This is a Title." The following line doesn't work because the regex group reference is lost (or so I assume). Is there an easy way to uppercase my matching letter in the replace function? replace( $input, '\b[a-z]' , upper-case('$0')) ...

Xpath function to remove white space

Hey everyone Im trying to use XSL and Xpath functions to remove all the white space from a XML attribute called name and make it lower case. At the moment i have something like <xsl:variable name="linkName"> <xsl:value-of select="normalize-space(name)"/> </xsl:variable> This removes the white space at the beginning and end but no...

How can i get some part of html using XPath?

I need to get some part of html pages using php XPath query (sorry im new to XPath). example html page <html><head>blah lines</head><body> <div id="mytable"> <table><tr><td>table cell value</td></tr></table> </div> <body><html> is there any way to get div contents of above example along with html tags using XPath ...

How can I get the XML nodes from this XML in classic ASP (MSXML)?

Hi all, OK, I'm at my wits end. This seems like it should be a completely trivial thing to do, yet after an hour I still just cannot make it work. I'm trying to get a list of time zones from the Campaign Monitor API; unfortunately the page I need to do this in is written in classic ASP/Javascript so I can't just use the API wrapper. I...

Varying xpath-default-namespace in XML source files

I have a set of XML files that I am processing with an XSL transform. They have a default namespace, so my XSL transform must contain the declaration: xpath-default-namespace="urn:CZ-RVV-IS-VaV-XML-NS:data-1.2.2" The problem is that this value changes from time to time, and my transform suddenly stops working, until I look at an exampl...

Is it there any XPath processor for SAX model?

I'm looking for an XPath evaluator that doesn't rebuild the whole DOM document to look for the nodes of a document: actually the object is to manage a large amount of XML data (ideally over 2Gb) with SAX model, which is very good for memory management, and give the possibility to search for nodes. Thank you all for the support! For all...

How to query this XML document in C#.NET 3.5

I have an XML document of the form: <metadata> <item name="Name" type="xs:string" length="102"/> <item name="Email" type="xs:string" length="202"/> </metadata> <data> <row> <value>Daniel</value> <value>[email protected]</value> </row> <row> <value>George</value> <value>george@no-...

Select value with Linux command xpath (from Perl)

I want to get an attribute out of a XML-Tree. Therefor I use the command xpath from package libxml-xpath-perl. I figured out this command: virsh dumpxml save | xpath -e "/domain/devices/disk[@type='file']/source/@file[1]" This gives me file="/var/lib/libvirt/images/save.raw" How can I select the value only? (/var/lib/libvirt/image...

BizTalk server problem

Hi, we have a biztalk server (a virtual one (1!)...) at our company, and an sql server where the data is being kept. Now we have a lot of data traffic. I'm talking about hundred of thousands. So I'm actually not even sure if one server is pretty safe, but our company is not that easy to convince. Now recently we have a lot of problems. ...

XML Schema (XSD): How to express "At most one element from group A and at most one element from group b"?

Say I have two sets of XML elements: <One/> <Two/> <Three/> And <A/> <B/> <C/> And I want to have them as children of a bucket element: <Bucket> <A/> <One/> </Bucket> Or <Bucket> <C/> <Two/> </Bucket> But I don't want to allow more than one element from either set of elements. I.e: <Bucket> <A/> <B/> <On...

Xpath Wildcard (for example: "/Data/Customers/D*")

I am selecting some nodes using XPath, and would like to use wildcards. Is this possible? Something like the following would be useful: foreach (XmlNode xml_node in xml_document.SelectNodes("/Data/Customers/D*")) { // } ...

using xml param inside a function

Having declared <xsl:param name='suffix'>some_string</xsl:param> I tried to use its value in a function call like this <xsl:when test='fn:ends-with(@name, {$suffix})'> which ended with the following error: XPST0003: XPath syntax error at char 20 on line 34 in {fn:ends-with(@name, {$}: Unexpected token "{" in path expr...

Returning a boolean from an XPath expression

We would like to implement existance checks of elements via XPath expression. The XPath expressions are defined externally. We are trying to use the XPathEvaluate extension method from System.Xml.XPath, but it complains when we try to do the following. XDocument d = new XDocument( new XElement("test", ...

XPath to fetch SQL XML value

I am looking for a good intro (not a book!) to XPath with SQL Server 2005. Anyone has a link for me? P.S. I don't really want to learn it (yet), I just want to fix my problem now :) So something with a bunch of examples would be useful. Thanks. Edit: Ok. Here is my problem: From the following XML that is within a column, I want to kn...

XPath + Firebug +XML/HTML +HTML AgilityPack C#

Hi! When using Firebug or some of the bookmarklets: javascript:(function(){var a=document.createElement("script");a.setAttribute("src","http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js");if(typeof jQuery=="undefined"){document.getElementsByTagName("head")[0].appendChild(a)}(function(){if(typeof jQuery=="undefined"){setTimeout(arg...

Basic simpleXML working example?

Hi It looks like there are many problems with simpleXML in PHP. I'm running the latest version of php on Windows and I just can not get the basic examples of simpleXML to work as in the documentation. My xml file is: <?xml version="1.0" encoding="ISO-8859-1"?> <programme> <title>Billy Bushwaka</title> <episodeNumber>2</epis...