xpathengines

Dom4j XPath distinguish null or empty string

I have an XML Schema element like this: <xs:element type="xs:string" name="IsActive" minOccurs="0"> </xs:element> I'm using dom4j XPath to evaluate the element. It seems impossible to determine whether element is present in the XML document or if its value is simply "". I want <IsActive> to be either, 1) "" 2) "anyvalue1" 3) "anyva...

XPATH contains(string, string) Not Working

sI have an XML file that looks like the following... <a> <b> <version>1.0</version> <c> <Module>foo.EXE</Module> </c> <c> <Module>bar.DLL</Module> </c> </b> </a> I have a COM DLL that uses MSXML2:IXMLDOMNode objects that call "selectNodes" something like... CComPtr<MSXML2::IXMLDOMNodeList> oR...

How to use multiple xpath selectors in a YQL query

Hey, I'd like to scrape some data from my blog using YQL: SELECT * FROM html WHERE url="http://site.com/blog" AND xpath="//div[@class='post']" How can I use different bits of xpath in my query? E.g. can I do something like: SELECT * FROM html WHERE url="http://site.com/blog" AND xpath="//div[@class='post']" AND xpath ="//div[@class='...

undefined method `xpath' for nil:NilClass (NoMethodError)

I'm getting the following error, seemingly randomly when trying to extract a href links from a nokogiri doc. Related code: nokohtml = page.doc nokohtml.xpath('//a/@href').each do |node| ...

Nokogiri, different results of xpath in JRuby

Hi, I am getting different results from the same xpath expression in nokogiri when using ruby and jruby, In ruby the following xpath expression returns a node while in jruby it returns a nodeset: parent = node.xpath("./ancestor::node()[name(.) = 'div' or name(.) = 'p'][1]") Has anybody else noticed similar behaviour? Thanks Paul ...

how to use XPATH process DOM node on ANDORID?

Hi folks, I am in a ANDROID project that use XPATH a lot. I followed the way in The Force Unleashed: XML+XPath On Android Using Dom4j And Jaxen. Everything's fine beside the performance. The XML file's big and read intensively. Following code consume 6 mins. org.dom4j.Document MatrixXML = (new org.dom4j.io.SAXReader()).read(this.getRe...

Match groups in Oracle 10g2 regular expressions

I need to extract some data from malformed XML stored in an Oracle database. The XPath expressions would look like this: //image/type/text(). One take at a regular expression which would work in a similar fashion would be <image>.*?<type>(.+?)<\/type> (with appropriate flags for multiline matching). Since Oracle does not support match g...

Get attribute using XPath with TinyXPath & TinyXML

I'm trying to write a function that will get me the attribute of a set of XML nodes in a document using XPath with the TinyXPath library, but I cannot seem to figure it out. I find the documentation on TinyXPath is not very enlightening either. Can someone assist me? std::string XMLDocument::GetXPathAttribute(const std::string& attrib...

Java: Using XPath to loop over nodes and extract specific subnode values

Hi I understand from various googling that it makes more sense to try to extract your data from XML using XPath than using DOM looping. At the moment I have implemented my solution to use DOM, but the code is verbose, it feels untidy and unmaintainable, so I would like to switch to a cleaner XPath solution. Lets say I have this structu...

Possible to parse this html with xpath?

Hello, I am working on gather sports statistics for a personal hobby project. I found this site with all the info I need:file:///Users/JohnJNichols4/Desktop/view-source%20cluster.leaguestat.com%20download.php%20client_code=ahl&file_path=daily-report%20daily-report.html Am I able to parse this site with xpath? I only have experience (...

XPath and Jabber-RPC

I'm trying to access the methodName element of an XML document using XPATH in Cocoa via the NSXMLElement object. This is the XML representation of element <iq type='set' from='[email protected]/jrpc-client' to='[email protected]/jrpc-server' id='rpc1'> <query xmlns='jabber:iq:rpc'> <methodCall> <m...

Parsing XML using libxml2 and Xpath in objective c

Hi, I want to parse an xml file using libxml2 and XPath I have tried to look this up on the internet but I can't find much about it. Can anyone give me a sample code for parsing this xml: <WebServiceResponse> <status>OK</status> <result> <type>sample</type> <name>Sample XML</name> <locati...

Accessing a node-set in a JavaScript XPath query

I have a real simple question that I can't seem to find an answer to. I want to compress two XPath statements (that are getting attribute values). I learned about the | operator, hearing how it returns node sets. var getdata = xmldoc.evaluate ( '/foo/bar[@world=\''+hello+'\']/child::*/attribute::name |/foo/bar[@world=\''hello+'...

can i use simpleXML & xpath to directly select an elements attribute?

i.e. - i want to return a string "yellow" using something like xpath expression "//banana/@color" and the following example xml... <fruits> <kiwi color="green" texture="hairy"/> <banana color="yellow" texture="waxy"/> </fruits> $fruits = simplexml_load_string( '<fruits> <kiwi color="green" texture="hairy"/> <banana color="yellow" ...

Limit XPath query in SSIS to a single element?

I have some large XML files to load via SSIS, and need to get an ID value from the first line of files, in order to get a key value to append to the imported rows: After this root element, there are many children (inidividual elements) which load fine. But when using an XML Task with an XPath query /sessions[1]/@accountId[1], it app...

XPath how to select the first element without loading the whole xml?

Hello everybody, Im using libxml2 on the iPhone with the nice Method: PerformXMLXPathQuery from Cocoa with Love. The problem is how to find out witch xml got sent without first parsing the whole document... I tried to use the @"/" query to retrieve the first element as written on the introduction of Cocoa with Love but unfortunately, th...