Hello Developers,

<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

SORTED...but i would like to ask developers here...how come this forum is so dead ???? Is it any good posting any queries in future or is it just a waste of time in this forum...
Thanks

Can any one help me out with the xpath for retreiving title "ABC Publication Listing" and also description "Alcohol and the lime in perspective"

First of all while giving any example write your xml properly.

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>

And your proposed output should look like-

<?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>

Then you can use following code

<?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 :)

This article has been dead for over six months. Start a new discussion instead.