0

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

2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by mlohokare
0

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

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"

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 topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.