xpath

A good resource for learning xsl?

Hey all Know a bit of XML but am struggling to get my head around XSL - just wondering if anybody knows of any good resources to get me up to par quickly. Websites or books etc. Thanks in advance. ...

xpath 'or' behaving like union ('|') with xmllib2

I have XML documents like: <rootelement> <myelement>test1</myelement> <myelement>test2</myelement> <myelement type='specific'>test3</myelement> </rootelement> I'd like to retrieve the specific myelement, and if it's not present, then the first one. So I write: /rootelement/myelement[@type='specific' or position()=1] The XPath spec ...

Performing a check in XSL

Hey I am trying to perform a check on individual nodes of an XML file, and depending on the contents of a specific node do something, for example if the type is bool display a checkbox or if the type is text display a textarea or a pull down options box. For example: <Questions> <Question> <Data>What gender are you?</Data> <Type>pulld...

XSLT with overlapping elements?

So the title of this post may be a little misleading, but it's the best I can come up with. I'm working on a project that uses TEI for encoding texts. One of the requirements of my current work is to write XSL transformations to render the XML-encoded texts as HTML. For the most part, no problem. I'm kind of stuck on this issue, thou...

Iterate and concat using XPath EXpression

hi everyone i have the following xml file <author> <firstname>Akhilesh</firstname> <lastname>Singh</lastname> </author> <author> <firstname>Prassana</firstname> <lastname>Nagaraj</lastname> </author> and i am using the following jxpath expression concat(author/firstName," ",author/lastName) to get the value Akhilesh Singh ,Prass...

XPath Performance in .NET with Positional Predicates

Given the XML <PSG> <C id="1"> <N id="2" > <A id="3" /> <D id="4"> <PP /> </D> <V id="5" > <Tn /> <P /> </V> <N id="6" > <D id="7" /> <D id="8" /> </N> ...

XSLT grouping continued - xPath issue??

Dimitre was a big help earlier... this is kinda like part two. :) I've been wracking my brain and still don't see it. Now that I'm able to isolate the Brands of the xml example below, now I'd like to isolate all the Product-Type's of the given $Brand in much the same way as I was able to isolate all the Brands. xml example (one member...

php simple_xml xpath issue for gpx file

I try to get the lat and lon's from a gpx file (GPS XML). When I do (snippet): $res = $xml->xpath('//*'); I get the full content returned. When I try to narrow down like this: $res = $xml->xpath('//rte'); I get nothing: array(0) { }. Even when the tag(s) exists. Actually whatever I try to fill in after // other then * it returns...

What is the safest way to extract <title> from an HTML file using xpath?

Here is my current xpath code "/html/head/title". But you know, in the real world html environment, the code format usually broken, e.g. <html> tag is missing could cause an exception. So, I would like to know if there's a safe way to extract the <title> tag? (something like getElementByTagName) ...

How to extract this format in xslt

Hi All, I have an xml structure: <Date>Mon, 11 Aug 2009 13:15:10 GMT</Date> i want to extract only 15:10 or '15' and '10'. What is the best way to do that using xslt ...

Trouble getting data out of a xml file

I am trying to parse out some information from Google's geocoding API but I am having a little trouble with efficiently getting the data out of the xml. See link for example All I really care about is getting the short_name from address_component where the type is administrative_area_level_1 and the long_name from administrative_area_le...

Check if a variable of the for-each is equal with an XML entry

I'm trying to add the attribute 'selected' to <option>. I've tried various ways and I can't get it working. This is how I'm trying it: <xsl:for-each select="page/index/values/albums"> <option> <xsl:attribute name="value"><xsl:value-of select="id" /></xsl:attribute> <xsl:if test="page/index/values/album = id"> ...

Use HtmlAgilityPack to divy up a document

I'm wondering if this is possible. I have html like so: <p> <font face="Georgia"> <b>History</b><br>&nbsp; <br>Two of the polysaccharides used in the manufacture of...</font> <a title="PubMed" href="http://www.www.gov/pubmed/" target="_blank"> <font face="Georgia">) and this web site for new development by...well as Self ...

SelectSingleNode returns nothing

I'm testing the SelectSingleNode function to fetch a single node from an XMLNode object in Visual Studio as follows: Dim nsmgr As XmlNamespaceManager = New XmlNamespaceManager(xmlDoc.NameTable) nsmgr.AddNamespace(ndListItems.Prefix, ndListItems.NamespaceURI) Dim dummy As XmlNode = ndListItems.SelectSingleNode("/l...

How do I use the translate function in a predicate of a XPath argument to XmlDocument.SelectNodes?

I'm using C# and .NET 2.0. Given the XML below, I'd like to get a XMLNodeList of <user> nodes where the <role> is "admin". <users> <user> <name>John Doe</name> <roles> <role>superadmin</role> <role>admin</role> </roles> </user> <user> <name>Jane Doe</name> <rol...

Why following XPath statement returns all "a" elements?

print $tree->findvalue('//a[1]'); I am using HTML::TreeBuilder::XPath in perl. Now i expect the above statment to return the value of second "a" element but instead it returns the value of all "a" elements in the page. I cant understand Why? ...

How to query XML nodes based on the value of the attribute of its parent node

I have an XML which looks something like this: <Library> <Author Name = "JRR Tolkien"> <Book Title = "Lord Of the Rings" /> <Book Title = "The Hobbit" /> </Author> <Author Name = "JK Rowling"> <Book Title = "Harry Potter and the Sorcerers Stone" /> <Book Title = "Harry Potter and the Prisoner of Azkaban" /> </Author> </Library> What i...

Hibernate dependency issue with maven and xml parsing

I'm writing a GWT-Hibernate internal web application for our development group. Previously, I had written tools to parse up XML files which represented customer configuration gathered in the field for analysis. Now, I'm trying to add an UI front-end for the support group. The XML parsing code uses xpath and org.w3c.dom classes to consum...

Yet another .NET XPath predicate question...

Given this XML, I want to retrieve a XmlNodeList of <member> nodes from <group> nodes whose <id> matches 'Tech'. The matching should be case-insensitive. <groups> <group> <id>Tech</id> <members> <member>johndoe</member> <member>janedoe</member> <member>ro...

Counting items of a rendered menu - PHP/Regex/XPath

Hi there! :D Guys, I need some help! I have a fully rendered menu (a safe html output)... and I need the number of <li> ONLY of its first level... example: <li><a>first</a></li> <li><a>first</a></li> <li> <a>first</a> <ul> <li><a>second</a></li> <li> <a>second</a> <ul> <li><a>third</a></li> </ul> ...