xpath

Which HTML element has the largest number of children of a certain type, for instance tags?

In any language, XSLT, PHP, Ruby, Perl, anything: how can I get the XPath or other path or identifier to the element containing the largest number of <p> tags? ...

Ruby XPath to find Attribute

What Ruby library can be used to select attribute using XPath, and to use it as the starting point for other XPath queries. Example: <root> <add key="A" value="B" /> <add key="C" value="D" /> <add foo="E" bar="F" /> </root> Desired code: get_pair "//*/@key", "../@value" get_pair "//*/@foo", "../@bar" Expected output: "A" "...

Create XPathDocument from XmlElement

I'm using a webservice which returns an XmlElement object to my c# program. I would like to read information from the XmlElement using Xpath. What is the best way to create an XPathDocument from the XmlElement? ...

Is there an XSLT name-of element?

In XSLT there is the <xsl:value-of select="expression"/> to get the value of an element, but is there something to select the tag-name of the element? In a situation like this: <person> <!-- required stuff --> <name>Robert</name> <!-- optional stuff, free form for future extension. Using XMLSchema's xsd:any --> <prof...

Using Xpath With Default Namespace in C#

I've got an XML document with a default namespace. I'm using a XPathNavigator to select a set of nodes using Xpath as follows: XmlElement myXML = ...; XPathNavigator navigator = myXML.CreateNavigator(); XPathNodeIterator result = navigator.Select("/outerelement/innerelement"); I am not getting any results back: I'm assuming this ...

How can I convert a string to upper- or lower-case with XSLT?

How do you do case conversion in XSL? <xsl:variable name="upper">UPPER CASE</xsl:variable> <xsl:variable name="lower" select="???"/> ...

xpath question on selecting node set

Hi, everyone: Here is a simplified version of my source xml document: <eml> <additionalMetadata> <describes>sbclter.380</describes> <access authSystem="knb" order="denyFirst"> <allow> <principal>public</principal> <permission>all</permission> </allow> </access> </additionalMetadata> <additi...

xpath and c#

Hi I am trying to create a winform application that searches through an XML doc. for my search I need to convert the the XML attribute in the xpath condition to lower case, by using lower-case() xpath function. this causes a problem related to the function namespace. I have tried to add the namespace manualy: XmlNamespaceMana...

Is there a maximum length for XPath Queries in MSXML?

I'm planning to do a relatively large XPath query using msxml. Is there a maximum length for a query that msxml enforces? Background: From some external input my code will create a number of xpath-queries and I am interested in the result of all those or-ed together: myObject.SelectNodes(subQuery1 +"|"+ subQuery2 +"|" + subQuery3 + ...

Need help with PHP DOM XPath parsing table

I just recently read about the DOM module in PHP and now I'm trying to use it for parsing a HTML document. The page said that this was a much better solution than using preg but I'm having a hard time figuring out how to use it. The page contains a table with dates and X number of events for the date. First I need to get the text (a da...

XPath count in VBScript

I am trying to get the number of specific nodes in an XML file using the XPath count function, however, this keeps returning an error "An exception of type 'msxml3.dll: Expression does not return a DOM node." How do I get the return value from an XPath count using VBScript and MSXML DOM Dim oXML Dim homeId Dim awayId Dim homeGoals ...

xpath expression for regex-like matching?

I want to search div id in an html doc with certain pattern. I want to match this pattern in regex: foo_([[:digit:]]{1.8}) using xpath. What is the xpath equivalent for the above pattern? I'm stuck with //div[@id="foo_ and then what? If someone could continue a legal expression for it. EDIT Sorry, I think I have to elaborate more...

How to import attributes and elements from XML to Filemaker?

I have an application that stores its user database to an XML file and I need to export selected fields to Filemaker so my client and mine the data on Filemaker. I managed to make XSLT file to import XML elements, but cannot seem to find a way to import any elements. Pointers in solving this problem are greatly anticipated. Example of t...

How to match a text node then follow parent nodes using XPath

I'm trying to parse some HTML with XPath. Following the simplified XML example below, I want to match the string 'Text 1', then grab the contents of the relevant content node. <doc> <block> <title>Text 1</title> <content>Stuff I want</content> </block> <block> <title>Text 2</title> <content>S...

Why XmlDocument throw when doing this XPath request ?

var xmlDoc = new XmlDocument(); xmlDoc.Load("XMLFile1.xml"); XmlNamespaceManager manager = new XmlNamespaceManager(xmlDoc.NameTable); manager.AddNamespace("frbny", "urn:toto"); var curs = xmlDoc.SelectNodes("/frbny:DataSet/frbny:Series/frbny:Key/frbny:CURR"); var values = xmlDoc.SelectNodes("/frbny:DataSet/frbny:Series/frbny:Obs/frbny:OB...

XPath 2.0: how to test that we have in a variable is an element?

Say I have a variable $foo. I'd like to use $foo castable as element(), but I can't use a node type after castable. ...

How to get the modulus of a number in XPath/XSLT?

I need to calculate the modulus of a number in XPath, but this won't work: <xsl:if test="(count()%8)"> How would I do it? Looked at the XPath function reference here, but didn't see anything like that. THANKS FOR THE PROMPT ANSWERS! ...

How to extract leaf nodes from Oracle XMLTYPE

I want to extract only the leaf nodes from an XMLTYPE object in Oracle 10g SELECT t.getStringVal() AS text FROM TABLE( XMLSequence( XMLTYPE( '<xml> <node> <one>text</one> </node> <node> <two>text</two> </n...

XPath to find nested values

I have some XML I'm having trouble processing with XPath. I can't seem to get the values I'm looking for. The XML is structured like this: <Group> <Menu> <Name>Top Menu</Name> <Document> <DocName>Readme.txt</DocName> </Document> <Menu> <Name>Sub Menu</Name> <Document> <...

Navigating to nodes using xpath in flat structure

I have an xml file in a flat structure. We do not control the format of this xml file, just have to deal with it. I've renamed the fields because they are highly domain specific and don't really make any difference to the problem. <attribute name="Title">Book A</attribute> <attribute name="Code">1</attribute> <attribute name="Author"> ...