| | |
XPath
Please support our XML, XSLT and XPATH advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Jan 2009
Posts: 4
Reputation:
Solved Threads: 0
Hello Developers,
Can any one help me out with the xpath for retreiving title "ABC Publication Listing" and also description "Alcohol and the lime in perspective"
Thanks a lot
Andyyy
XML, XSLT and XPATH Syntax (Toggle Plain Text)
<p class="abc-srch-Metadata"><span class="abc-srch-URL"><a href="http://www.abc.ac.uk/pub/xyz.aspx?e=20" id="CSR_U_2" title="http://www.abclondon.ac.uk/pub/xyz.aspx?e=20" dir="ltr">http://www.abclondon.ac.uk/pub/xyz.aspx?e=20</a></span> - 13KB </p><span class="abc-srch-Icon"><a href="http://www.abclondon.ac.uk/pub/pqr.aspx" id="CSR_IMG_3" title="http://www.abclondon.ac.uk/pub/pqr.aspx"><img align="absmiddle" src="/_layouts/images/html16.gif" border="0" alt="File with extension: aspx"></a></span><span class="abc-srch-Title"><a href="http://www.abclondon.ac.uk/pub/xyz.aspx" title="http://www.abclondon.ac.uk/pub/xyz.aspx">ABC Publications Listing </a><br></span><div class="abc-srch-Description">Alcohol and the <b>lime</b> in perspective
Can any one help me out with the xpath for retreiving title "ABC Publication Listing" and also description "Alcohol and the lime in perspective"
Thanks a lot
Andyyy
•
•
Join Date: Oct 2008
Posts: 22
Reputation:
Solved Threads: 0
•
•
•
•
Can any one help me out with the xpath for retreiving title "ABC Publication Listing" and also description "Alcohol and the lime in perspective"
if your xml looks like
•
•
•
•
<test>
<p class="abc-srch-Metadata"><span class="abc-srch-URL"><a href="http://www.abc.ac.uk/pub/xyz.aspx?e=20" id="CSR_U_2" title="http://www.abclondon.ac.uk/pub/xyz.aspx?e=20" dir="ltr">http://www.abclondon.ac.uk/pub/xyz.aspx?e=20</a></span>-13KB</p>
<p><span class="abc-srch-Icon"><a href="http://www.abclondon.ac.uk/pub/pqr.aspx" id="CSR_IMG_3" title="http://www.abclondon.ac.uk/pub/pqr.aspx"><img align="absmiddle" src="/_layouts/images/html16.gif" border="0" alt="File with extension: aspx"/></a></span><span class="abc-srch-Title"><a href="http://www.abclondon.ac.uk/pub/xyz.aspx" title="http://www.abclondon.ac.uk/pub/xyz.aspx">ABC Publications Listing </a><br/></span></p><div class="abc-srch-Description">Alcohol and the <b>lime</b> in perspective</div>
<p class="abc-srch-Metadata"><span class="abc-srch-URL"><a href="http://www.abc.ac.uk/pub/xyz.aspx?e=20" id="CSR_U_2" title="http://www.abclondon.ac.uk/pub/xyz.aspx?e=20" dir="ltr">http://www.abclondon.ac.uk/pub/xyz.aspx?e=20</a></span>-13KB</p>
<p><span class="abc-srch-Icon"><a href="http://www.abclondon.ac.uk/pub/pqr.aspx" id="CSR_IMG_3" title="http://www.abclondon.ac.uk/pub/pqr.aspx"><img align="absmiddle" src="/_layouts/images/html16.gif" border="0" alt="File with extension: aspx"/></a></span><span class="abc-srch-Title"><a href="http://www.abclondon.ac.uk/pub/xyz.aspx" title="http://www.abclondon.ac.uk/pub/xyz.aspx">ABC TEST Listing </a><br/></span></p><div class="abc-srch-Description">Alcohol and Nothing</div>
</test>
•
•
•
•
<?xml version="1.0" encoding="UTF-8" ?>
<chk>
<p>Title: ABC Publications Listing AND Description: Alcohol and the lime in perspective AND Description: Alcohol and Nothing</p>
<p>Title: ABC TEST Listing AND Description: Alcohol and the lime in perspective AND Description: Alcohol and Nothing</p>
</chk>
•
•
•
•
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output encoding="UTF-8" method="xml" indent="yes" />
<xsl:template match="/ | @* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="/">
<chk>
<xsl:for-each select="//*[@class='abc-srch-Title']">
<p>Title: <xsl:value-of select="." /><xsl:for-each select="//*[@class='abc-srch-Description']"> AND Description: <xsl:value-of select="." /></xsl:for-each></p>
</xsl:for-each>
</chk>
</xsl:template>
</xsl:stylesheet>
Cheers,
Mahesh
![]() |
Similar Threads
- Xpath (XML, XSLT and XPATH)
- Xpath navigation in xml file (XML, XSLT and XPATH)
Other Threads in the XML, XSLT and XPATH Forum
- Previous Thread: XSLT newbie
- Next Thread: Converting XPath without namespace to namespace XPath
Views: 550 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for XML, XSLT and XPATH
api blogger blogging code dataset delete development dynamiccreationofnvariablesinxslt error firstthreecharacterofastringrequired flipbook gdata google html include java link linspire linux microsoft news node openoffice overwrite precedence programming rss serialization standards swf template transform variable w3c web xml xmlnotloading xmlonserver xsl xslt





