Hi, I've never asked a question here before so please forgive my question if its formatted badly or not specific enough. I am just a dabbler and know very little about PHP and XPath.
I have an XML file like this:
<catalogue>
<item>
<reference>A1</reference>
<title>My title1</title>
</item>
<item>
<reference>A2</reference>
<t...
The following code gives me a nodeList to itterate over:
XPathNavigator thisNavigator = thisXmlDoc.CreateNavigator();
XPathNodeIterator dossierNodes = thisNavigator.Select("changedthisname/dossiers/dossier");
I am processing this nodeList, and i need to grab another nodelist out of this list.
I am trying to do this by using this code...
Consider the following code :
$dom = new DOMDocument();
$dom->loadXML($file);
$xmlPath = new DOMXPath($dom);
$arrNodes = $xmlPath->query('*/item');
foreach($arrNodes as $item){
//missing code
}
The $file is an xml and each item has a title and a description.
How can I display them (title and description)?
$file = "<item>
<title>t...
I am using xPath to do some ETL work from a dictionary lookup file. I need to be able to look for the translation key and return the translated value. For example I need to be able to look for "prioremployment" and have it return "Prior Employment".
This will return an array of all the translate nodes (I am using ColdFusion 9):
XMLSea...
Hi,
I'd like to use Nokogiri to extract all nodes in an element that contain a specific attribute name.
e.g., I'd like to find the 2 nodes that contain the attribute "blah" in the document below.
@doc = Nokogiri::HTML::DocumentFragment.parse <<-EOHTML
<body>
<h1 blah="afadf">Three's Company</h1>
<div>A love triangle.</div>
<b b...
Hi everyone here.
We can use the XPathEvaluator object(in javascript) to do xpath evaluation on Safari,Google Chrome and Safari on Iphone. But on android the browser said that the XPathEvaluator object is undefined.
So how can I get a instance of XPathEvaluator object, or is there any other solution to perform xpath evaluation on andro...
Consider the following XML:
<response>
<status_code>200</status_code>
<status_txt>OK</status_txt>
<data>
<url>http://bit.ly/b47LVi</url>
<hash>b47LVi</hash>
<global_hash>9EJa3m</global_hash>
<long_url>http://www.tumblr.com/docs/en/api#api_write</long_url>
<new_hash>0</new_hash>
</data>
</response>...
I would like a brief and easy way to strip tags from an XHTML document, and believe there has to be something curt enough among all the options like: XSLT, XPath, XQuery, custom C# programming using the .NET XML namespace. I'm open to others.
For example, I want to strip all <b> tags from an XHTML document but
keep their inner cont...
I am using Xalan 2.7.0 (as bundled with Apache FOP 1.0) and have problems when using string functions.
The line <xsl:value-of select="fn:replace('test', 't', '*')"/> results in this exception:
javax.xml.transform.TransformerException: java.lang.IllegalArgumentException: argument type mismatch
at org.apache.fop.cli.InputHandler.tran...
I am setting a xslt param with PHP, and then calling the transform. I want to use the param value in an XPath expression to grab the proper nodes, but this doesn't seem to be working. I am guess it's possible, I think I am just missing the syntax. Here what I have...
PHP:
$xslt->setParameter('','month','September');
XSL:
<?xml versi...
I have a small problem with Xpath contains with dom4j ...
Lets say my XML is
<Home>
<Addr>
<Street>ABC</Street>
<Number>5</Number>
<Comment>BLAH BLAH BLAH <br/><br/>ABC</Comment>
</Addr>
</Home>
Lets say I want to find all the nodes that have ABC in the text given the root Element...
So the xpath tha...
I have a xml file
<?xml version="1.0" encoding="UTF-8"?>
<xml>
<settings>
<title>Calendar for September</title>
<subTitle>Calendar for September Calendar for September</subTitle>
</settings>
<events date="06-09-2010">
<event id="2">
<title>This is My Second Event</title>
<description>This is My Second Event </description>
</event>
<eve...
I am new to programming. I know what XML is. Can anyone please explain in simple terms what xpath and xquery do Where are they used?
...
I know how to quickly extract text nodes from a DOM:
document.evaluate('//text()', document, null, XPathResult.ANY_TYPE, null)
But is there an easy way to exclude text from SCRIPT, STYLE, or other tags that are not shown to the user?
Something like:
'//text()[ parent.name not in ("SCRIPT", "STYLE") ]'
Thanks,
Mike
...
Hello,
I'm using a Java application based on Saxon for the XPath parser. Please consider the following:
<import>
<record ref="abc">
<id>123</id>
<data>Value<data>
</record>
<record ref="def">
<parent>123</parent>
<data>Value2</data>
</record>
</import>
My use case is, I'm looping through the...
I'm trying to parse a page with links to articles whose important content looks like this:
<div class="article">
<h1 style="float: none;"><a href="performing-arts">Performing Arts</a></h1>
<a href="/performing-arts/EIF-theatre-review-Sin-Sangre.6517348.jp">
<span class="mth3">
<span id="wctlMiniTemplate1_ctl00_ctl00_ctl01_...
I'm trying to query some XML in SQL Server but am having difficulties:
Here is some sample XML:
<BaseReport>
<Parties>
<Party>
<SubjectType>
<ListItem Name="SubjectType1Name" />
<ListItem Name="SubjectType2Name" />
</SubjectType>
</Party>
<Party>
<SubjectType>
<ListItem Name="SubjectType...
I'm in a situation where I can only test for the child node, but I have to apply tags to the grandparent of this child node.
I've tried using:
<xsl:call-template name="grandparent" select="parent::parent::node()"/>
and:
<xsl:call-template name="grandparent" select="ancestor::node [@nameofgrandparentnode]"/>
But neither works.
Th...
I'm writing a Selenium testcase. And here's the xpath expression I use to match all 'Modify' buttons within a data table.
//img[@title='Modify']
My question is, how can I visit the matched node sets by index? I've tried with
//img[@title='Modify'][i]
and
//img[@title='Modify' and position() = i]
But neither works..
I also tri...
Let us have a xml tree of depth N. I have traveresd the last node means i am at last note. Now i wanted to go back to some level up (say at N-3) in the xml tree from that last node.
Please let me know the syntax for the XPATH query so that i can reached at intended node in the xml tree.
...