xpath

get everything inside/between html tags

Hi, what is the best way to get some html elements + values? example: <div id="abc" class="classs"> <img src="pic1.png" alt="pico"> <img src="pic2.png" alt="nano"> </div> what I have is the id=abc of the div element. I want to get everything inside the div element like: class of the div ("classs") src of the pictures and oth...

How can this xpath query (PHP) be more flexible?

I'm parsing an XHTML document using PHP's SimpleXML. I need to query a series of ul's in the document for a node containing a specific value, then find that node's parent's direct previous sibling... code will help explain! Given the following dummy xhtml: <html> <head></head> <body> ... <ul class="attr-list"> <li>Active Life (ac...

Parsing XML in Python using Expat

Background: I'm coming from C#-land, so I'm looking for something like being able to handle nodes and values by selecting via Xpath. Here's my code, so far: import urllib import sys from xml.parsers import expat url = 'http://SomeWebService.SomeDomain.com' u = urllib.urlopen(url) Parser = expat.ParserCreate() data = u.read() try: ...

Xerces + Python?

Does anyone know if there's an available python library compatible with Python2.6 that exposes the Xerces functionality and its XML DOM capabilities? I would define the desired capabilities as: XML DOM select by Xpath & XSLT processor. ...

Why does this xpath not evaluate to true?

I'm trying to evaluate an xml node using xpath and i'm not sure why it's not evaluating to true. xml <?xml version="1.0"?> <users> <user> <username>tom</username> <password>d644cd4b1c72f563855e689d46d9198e</password> </user> <user> <username>jeff</username> <password>smith</password> </us...

Splitting xml level according to Xpath

Can I split a level of an XML document with an XPath expression into a list? I have this, for example: <root> <test1 /> <testX /> <test2 /> <test21 /> <testX /> <test3 /> </root> so running it on this returns a list with <test1 />, <test2 /><test21 /> and <test3 />. There is not necessarily just one node between <testX /...

Speeding up xpath

Hello, i have a 1000 entry document whose format is something like <Example> <Entry> <n1></n1> <n2></n2> </Entry> <Entry> <n1></n1> <n2></n2> </Entry> <!--and so on--> There are more than 1000 Entry nodes here. I am writing a Java program which basically gets all the...

shorten xml file loading time

I have the below code. It works fine, but it takes too long to load, well about 30 seconds. Is there anything I can do to shorten this time. Also, I would like to search the xml file for documents with NAME starting with A,B,C etx. How do I do that? Many thanks, Dim xdoc As New XPathDocument(xt) Dim nav As XPathNavigator = xdoc...

Lxml or Xpath content print

I have the following function def parseTitle(self, post): """ Returns title string with spaces replaced by dots "" return post.xpath('h2')[0].text.replace('.', ' ') I would to see the content of post. I have tried everything I can think of. How can I properly debug the content? This is an website of movi...

Get tag name and value of a given node using XMLReader, DOM, Xpath

I need to query an xml document and then display specific tag values, e.g. forename, surname, group(dept), job_title. I'm using XMLReader as i may need to work with large XML files. I using DomXPath to filter the data, but i don't know how to retrieve the nodeName and value for each element. The code below only returns 'member' as the...

SQL Server 2008: SQLXML Query function .query('//mypath/text()') doesn't XML decode

In Microsoft SQL Server 2008, when executing .query('{xpath}/text()') on an XML stream column value, if the value of the XPath selected node contains "&amp;", the return value is "&amp" instead of "&". Is this a bug, or am I doing something wrong? Or rather, how do I get the unencoded text, i.e. equivalent of .innerText (per W3C XML DOM...

obtain the node value as text with php + xpath

How can I just obtain the string value of a Xml node using xpath in PHP? I RTFM but there is more complicated situations, using foreach I want just my node text. XML: <ValCurs Date="00.00.0000" name="Official exchange rate"> <Valute ID="47"> <NumCode>978</NumCode> <CharCode>EUR</CharCode> <Nominal>1</Nominal> <Name>Euro</Name> ...

Parsing SOAP XML in Oracle

Hi I am new to Oracle and I am working on something that needs to parse a SOAP request and save the address to DB Tables. I am using the XML parser in Oracle (XMLType) with XPath but am struggling since I can't figure out the way to parse the SOAP request because it has multiple namespaces. Could anyone give me an example? Thanks in ...

How to get element type in xpath?

My xml is: <record> <field name="f1"/> <id name="f2"/> <id name="f3"/> <field name="f4"/> <info/> </record> I want to loop through it in xquery like this: for $i in $records/record/field | $records/record/id return if ( .... $i is id .... ) then .... do something .... else ... do something else ... Is this possible? Ho...

Could anyone help me fix this xpath expression?

Hi all.. Time for another silly question :) I got some tables in a xhtml-document with class="mytable" and inside those tables all sorts of elements, including <input type="checkbox"/> .. Now, I need to select all these checkboxes. I figured I'd use jquery with xpath, but my expression doesnt seem to work. So far, I've come up with ...

How do I use XPath to count the number of nodes with a certain attribute

I can't seem to get an XPath expression to work for my scenario. I want to find all the "Device" nodes that have the type "EndDevice". I'm able to count all the "Device" nodes, and I'm also able to find all "Device" nodes with the "EndDevice" attribute. However, I can't seem to combine them! count(//Device) //works //Device[@xsi:type='E...

How to get a value from an xml directly (preferably using XPath)?

I am trying to get comp1's value in the most simple way in C#. I want to be able to do it with a way that requires least checkes whether an element like Primary is there, etc. i.e. // pseudo code xmlItem = root.SelectSingleNode "/Primary/Complex?Name='comp1'" So I can just check if xmlItem is null, or has no elements, instead of doi...

Best way to substract form input fields html

How would you best get all the input fields (text, radiobutton, checkbox, select etc) semi-automatically out of dodgy formatted html documents? Trying to get the TYPE,NAME,VALUE and OPTION for SELECT. I am currently using Xpath (in PHP) because everyone here says 'use that instead' but I'm getting nowhere with it. So I am open to sugge...

help needed with xpath ...please

I'm trying to write xpath for one of the elements in a tree-like structure in the UI. The tree looks like a windows file structure, like parent node, child. So, in order to find child node parent node has to be clicked. + [file icon] Book |_ Book 1 |_ Book 2 |_ Book 3 Selenium gives the following xpath for the text 'Book' in above tr...

PHP Xpath : get all href values that contain needle

Working with PHP Xpath trying to quickly pull certain links within a html page. The following will find all href links on mypage.html: $nodes = $x->query("//a[@href]"); Whereas the following will find all href links where the description matches my needle: $nodes = $x->query("//a[contains(@href,'click me')]"); What I am trying to achi...