xpath

Fast python XML validator with XPath support

I need to read a large XML (65 Mb), validate it against a xsd, and run XPath queries on it. Below, I've given an lxml version of that. It takes a lot of time (over 5 minutes) to run the query but validation seems to be pretty quick. I've a couple of questions. How would a performance minded Python programmer write the program using lxm...

PHP XML manager/Xquery creator?

Hi, i'm looking for a PHP solution to easily traverse (readonly) XML files (rss feeds) from websites. Other providers have XML feeds with different markups and I want to have an easy PHP (possible self-built) manager to just enter an URI and then immediately be able to 'select' nodes/attributes/nodegroups to create somesort of definitio...

xpath expression to select text from link

I have such content of html file: <a class="bf" title="Link to book" href="/book/229920/">book name</a> Help me to construct xpath expression to get link text (book name). I try to use /a, but expression evaluates without results. ...

Namespace Manager or XsltContext needed

i am trying to read the following and select a node in it <ns1:OrderInfo xmlns:ns1="http://xxxxxx Some URL XXXX"> <pricing someAttrHere> <childnodes> </pricing> </ns1:OrderInfo> . XmlDocument document = new XmlDocument(); document.Load(Server.MapPath("order.xml")); XmlNamespaceManager manager = new XmlNamespaceManager(d...

Get xpath of xml node within recursive function

Lets say i have some code to iterate through an XML file recursively like this: $xmlfile = new SimpleXMLElement('http://www.domain.com/file.xml',null,true); xmlRecurse($xmlfile,0); function xmlRecurse($xmlObj,$depth) { foreach($xmlObj->children() as $child) { echo str_repeat('-',$depth).">".$child->getName().": ".$subchild."\n"; ...

Why can't I select the desired node using this PHP Xpath expression ?

Using PHP, SimpleXML and the xpath() function, I want to select a child node, starting from a certain point. Can you please help me? I know in this specific case I could use an expression starting with "//", but I want to learn the right way of selecting a child node. Thanks. First try -- fails with Undefined offset: 0 error $navXmlOb...

XPath to check if all provided pairs of elements exist for an entry

I have the following XML stored in an XML field in a SQL Server 2008 database. <attributes> <attribute> <key>animal</key> <value>rat</value> </attribute> <attribute> <key>color</key> <value>black</value> </attribute> </attributes> I'm able to select all the entries from the table which have an 'animal' key with...

XPath Select node from current node value when the two attribute names are the same

Hi all, Can anyone help me with this little issue I am having. The XML <MPN> <MTR MSN="AB123456"/> <MTR MSN="AB654321"/> <MTR MSN="AB654322"/> <MTR MSN="AB654323”/> <MTR MSN="AB654324"/> <JOB JobId="136"> <JMR MSN="AB123456"> <JRA DateActionRequiredBy="20090701120012" /> </JMR> ...

Using ms: xpath functions inside XPathExpression

I am trying to use Microsoft XPath Extension Functions (such as ms:string-compare http://msdn.microsoft.com/en-us/library/ms256114.aspx) inside an XPathExpression object. These functions are extensions inside the MSXML library, and if I use them in an XslCompiledTransform (simply adding the "ms" namespace) they work like a charm: ...

How to select nodes that has X as descendant using xpath

consider following example: <root> <instruments> <flute> <baz>bazik</baz> </flute> <guitar> <deep> <baz>more bazik</baz> </deep> </guitar> <drum> <foo>fooled</foo> </drum> </instruments> </root> I want to select flute and guitar because they both...

XPath Expression returns nothing for //element, but //* returns a count.

I'm using XOM with the following sample data: Element root = cleanDoc.getRootElement(); //find all the bold elements, as those mark institution and clinic. Nodes nodes = root.query("//*"); <html xmlns="http://www.w3.org/1999/xhtml" xmlns:html="http://www.w3.org/1999/xhtml"&gt; <head> <title>Patient Information</title> <...

Using an XPath-style Query with Reflection

I have a class tree, which contains multiple objects in a hierarchy. So I might have a Container object, which hosts 3 SubContainer objects, which in turn host an arbitrary number of Item objects. Is there any way that I can use an XPath-style expression over this object tree, which would imply reflection, so that I could query a proper...

XPATH Query not return result

Hi given the following Code: private void extractLink(ScriptFile file) throws SAXException, IOException, ParserConfigurationException, XPathExpressionException { Document d = this.parseFile(file); XPathFactory xpf = XPathFactory.newInstance(); XPath xpath = xpf.newXPath(); XPathExpression expr = xpath.compile("//link"); Obj...

How can I evaluate an XPath expression in Silverlight?

I need to allow an advanced user to enter an XPath expression and show them the value(s) or nodes or attributes found. In the .Net framework, the System.Xml.XPath.Extensions can be used to call XPathEvaluate, but Silverlight doesn't have this MSDN reference. Has anyone rewritten the extension methods for use in Silverlight? What is the b...

Using Variables in <xsl:sort select=""/>

Hi am build a generic template to list my content. But the Content may be sorted on different @'s or node()'s. So want to pass the xPath in. <xsl:variable name="sort" select="@sortBy"/> <xsl:variable name="order" select="@order"/> <xsl:for-each select="Content[@type=$contentType]"> <xsl:sort select="$sort" order="{$order}" data-type...

help needed with xpath and selenium

selenium IDE gave me following xpath for string on page called "System". However this string may appear somewhere other than this place in future. //ul[@id='idCTree_sor_ul']/li/ul/li[23]/span how can I rewrite above xpath by spcifying text()="System" in xpath , so in future if index of that string is moved would not impact on my xpath...

display xml data

Hi Thanks for suggestion given in http://stackoverflow.com/questions/2327734/search-dataset-from-xml-file to use Xpath instead of dataset as in my previous post. I've successfully filtered my xml data (see previous post) using xpath but now I need to display data in a table. How do I do this? I would need to display certain values. How...

Don't understand why I am getting this - 'Error: Value storage corrupted: negative offset'

Hi, I just started using IntelliJ-IDEA, and I don't know if the problem resides with the IDE or not. I'm assuming not but I have no idea. I've spent quite a lot of time googling this error to no avail. The error comes about at compile time. The weird thing is that I returned my code to the way it was before the error was showing up and...

alternative to ancestor-or-self ( or select all nodes in the tree with a specific child node)

I am trying to identify all the nodes in a tree that lead to a specific node. I am trying to accomplish this through either MSSQL XML (2005) or by the Microsoft.XMLDOM in ASP classic. I know the logic with XPATH but SQL Server does not support the ancestor-or-self axis and XMLDOM seems to choke on the :: notation.. The xpath that work...

project management question

1) Hydrobuck Hydrobuck is a medium-sized producer of petrol-powered outboard motors. In the past, he was has successfully manufactured and marketed motors in the 3 to 40 horsepower range. Executives at hydrobuck are now interested in larger motors and would eventually like to produce motors in the 50 to 150 horsepower range. The i...