Niaz Hussain
Niaz Hussain

Reputation: 147

Extract data from External XML file using XSL

I am using given below code in XSL file Both xsl and Results.xml are at same location but it cant give output.actually i want to access nodes of Results.xml file to extract data.

<xsl:variable name="fi" select="document('Results.xml')"/>
            <b><xsl:value-of select="$fi/Report/Doc/DName"/></b>

Upvotes: 1

Views: 7225

Answers (1)

siva2012
siva2012

Reputation: 459

When the below XSLT

<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml"/>
<xsl:template match="/">
<xsl:variable name="fi" select="document('Results.xml')"/>  
            <b><xsl:value-of select="$fi/Report/Doc/DName"/></b>
</xsl:template>
</xsl:stylesheet>

transforms below XML

<?xml version='1.0'?>    
<Report>
    <Doc>
        <DName>Sample</DName>
    </Doc>
</Report>

gives the required output

<?xml version='1.0' ?>
<b>Sample</b>

Upvotes: 2

Related Questions