Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Convert xml file to plain text file

From: "Hans" <hans@------.--->
To: NULL
Date: 6/14/2007 1:39:00 PM

Hi!

I have an xml file where I want to extract certain texts and create a text 
file.

<?xml version="1.0" encoding="UTF-8"?>
<HEADER>
<ROWS>
<ROW>
<TEXT>TEST row1</TEXT>
</ROW>
<ROW>
<TEXT>TEST row 2</TEXT>
</ROW>
<ROW>
<TEXT>TEST row 3</TEXT>
</ROW>
</ROWS>
</HEADER>


will output a textfile with
Test row1
Test row2
Test row3

I have not worked much with xsl but I tried to create a stylesheet like

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
version="1.0">
<xsl:output method="text" />
<xsl:template match="/">
    <xsl:apply-templates  select="HEADER/ROWS/ROW"/>
</xsl:template>

<xsl:template match="HEADER/ROWS/ROW">
    <xsl:value-of select="TEXT" />
</xsl:template>

</xsl:stylesheet>

And then call (from VB6 where doc is a domdocument that contains the xml 
document, stylesheet is also a domdocument holding the styleheet and 
MyStream is a Adodb.Stream object)
doc.transformNodeToObject stylesheet, MyStream
MyStream.SaveToFile("c.\test.txt")


but the file is always empty.



Regards
/Hans 




transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent