xpath

Does an XPathDocument load the whole xml document?

If I do XPathDocument doc = new XPathDocument("filename.xml"); Does that load the entire document into memory? I'm writing a mobile phone app and the document might store lots of data that doesn't ever need to all be loaded at the same time. Mobile phones don't usually have too much ram! ...

using xpath or css : How to get something which is selected on page

using xpath or css : How to get something which is selected on page using following html code. in following code, Element1 is selected on page and I wanted to find name of element that is selected on page. <div id="idc" class="tre"> <ul id="idCatT_srt_ul" class="abc"> <li class="treN treB treSelected" title="Element1 title"> ...

xslt and xpath: match preceding comments

given this xml: <root> <list> <!-- foo's comment --> <item name="foo" /> <item name="bar" /> <!-- another foo's comment --> <item name="another foo" /> </list> </root> I'd like to use a XPath to select all item-nodes that have a comment immediately preceding them, that is I like to selec...

Parse HTML with CSS or XPath selectors?

My goal is to parse HTML with lxml, which supports both XPath and CSS selectors. I can tie my model properties either to CSS or XPath, but I'm not sure which one would be the best, e.g. less fuss when HTML layout is changed, simpler expressions, greater extraction speed. What would you choose in such a situation? ...

Running XPath on child node.

Hi. I'm trying to do a xpath lookup on nodes returned by xpath lookup, but it doesn't seem to work as I expected.XPaths executed on the child nodes of a document seem to be executd against hthe root node of the document (in the example, the inventory tag.), instead of the root of the provided node. Am I missing something here? I'm new ...

Xpath to get the 2nd url with the matching text in the href tag

A html page has paging links, 1 set at the top of the page and another on the bottom of the page. Using HtmlUnit, I am currently getting the HtmlAnchor on the page using getByAnchorText("1"); There is a problem in some of the links on the top, so I want to reference the bottom links using XPath. nextPageAnchor = (HtmlAnchor) page.getB...

Optional Fields in InfoPath; Getting the XML node with VB

I use VB to get data through my form. I have some optional fields in my form and I have a problem with the following code: MsgBox(myXPathNavigator.SelectSingleNode( _ "/my:Status/my:Questions/my:Questions1", Me.NamespaceManager _ ).IsNode.ToString) When the optional field 'Questions1' is inserted into the form I get the value 'true'...

Check for default value of attribute in XPath

Hi, i have XML schema: <xsd:complexType name="contactsType"> <xsd:sequence> <xsd:element name="contact" type="contactType" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> <xsd:attribute name="visible" type="xsd:boolean" default="true"/> </xsd:complexType> and i want to find all contacts which have @visible=true, //co...

Using normalize-string XPath function from SQL XML query ?

Hi, is it possible to run an SQL query, with an XPath "where" clause, and to trim trailing spaces before the comparison ? I have an SQL XML column, in which I have XML nodes with attributes which contain trailing spaces. I would like to find a given record, which has a specified attribute value - without the trailing spaces. When I tr...

How to ignore first element in xpath

How can I ignore first element and get rest of the elements? <ul> <li><a href="#">some link</a></li> <li><a href="#">some link 2</a></li> <li><a href="#">link i want to find</a></li> </ul> Thanks ...

extract specific element from nested elements using lxml html

Hi all I am having some problems that I think can be attributed to xpath problems. I am using the html module from the lxml package to try and get at some data. I am providing the most simplified situation below, but keep in mind the html I am working with is much uglier. <table> <tr> <td> <table> <tr><td></t...

Using XPath to access comments a flat hierachy

I have a given XML document (structure can not be changed) and want to get the comments that are written above the nodes. The document looks like this: <!--Some comment here--> <attribute name="Title">Book A</attribute> <attribute name="Author"> <value>Joe Doe</value> <value>John Miller</value> </attribute>...

XSL last non-empty node

Given the following XML I need to place the contents of the suffix tag (minus the suffix tag itself) directly at the end of the last non-empty text node of a quote-block (as noted with comments in XML). My current code mostly works (stylesheet below) but I can't seem to correctly limit the the appended suffix content to just the last n...

How do I match contents of an element in XPath (lxml)?

I want to parse HTML with lxml using XPath expressions. My problem is matching for the contents of a tag: For example given the <a href="http://something"&gt;Example&lt;/a&gt; element I can match the href attribute using .//a[@href='http://something'] but the given the expression .//a[.='Example'] or even .//a[contains(.,'Examp...

Accessing the value of an input element with XPath in an XSLT

Hi! I'm developing a web app for Firefox that has a button that triggers a client-side XSLT transformation of the document's DOM, with a stylesheet fetched via AJAX. Here's a portion of the XHTML that's going to be transformed: <html> <head> <title>Static Javascript-based XMR Form Creator</title> </head> <body> <h1 id="title">...

TCL tDom Empty XML Tag

I'm using tDom to loop through some XML and pull out each element's text(). set xml { <systems> <object> <type>Hardware</type> <name>Server Name</name> <attributes> <vendor></vendor> </attributes> </object> <object> <type>Hardware</type> <name>Server Two Name</name> <attributes> <vendor></vendor> </attribute...

XDocument change all attribute names

I have an XDocument that looks similar to <root> <a> <b foo="1" bar="2" /> <b foo="3" bar="4" /> <b foo="5" bar="6" /> <b foo="7" bar="8" /> <b foo="9" bar="10" /> </a> </root> I wish to change the attribute foo to something else, and the attribute bar to something else. How...

PHP Getting XPath of a DOMNode

I am creating an XML document on the fly. and I need to know the XPath of the Node I've just created. I don't see any such function like DOMNode::calculateXPath(void):string and I am not willing to write one by my own. is there any known lite 3rd party Solution ?? ...

PHP DOMXml XPath of recursive Xpointer

My xml document reflects an Object. as referential Recursion is possible in objects and arrays. I need to reflect that in reproduced XML Structure too. Currently I am using Unique IDs to identify each node separately and a node like <recursion refer="IDREF"> and specifying the ID of the referenced Element. But in This way I need My Own C...

Count Total Number of XmlNodes in C#

Hey, I'm trying to find a way to get the total number of child nodes from an XmlNode recursively. That it is to say I want to count all the children, grand children etc. I think its something like node.SelectNodes(<fill in here>).Count but I don't know what the XPath is. Thanks ...