Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


WebService output > Tab-separated text?

From: mvexel@-----.--- (------- --- ----)
To: NULL
Date: 11/2/2004 7:08:00 AM
Hi all,

I'm receiving output from a webservice formatted as follows: 

<?xml version="1.0" encoding="utf-8"?>
<DataSet xmlns="http://tempuri.org/adrloc/levering">
  <xs:schema id="Bridgis_DataSet" xmlns="" 
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-
microsoft-com:xml-msdata">
    <xs:element name="Bridgis_DataSet" msdata:IsDataSet="true">
      <xs:complexType>
        <xs:choice maxOccurs="unbounded">
          <xs:element name="Bridgis_DataTable">
            <xs:complexType>
              <xs:sequence>
                <xs:element name="PSTK" type="xs:string" minOccurs="0" />
                <xs:element name="STRAAT_NEN" type="xs:string" 
minOccurs="0" />
                <xs:element name="STRAAT_PTT" type="xs:string" 
minOccurs="0" />
                <xs:element name="STRAAT_OFF" type="xs:string" 
minOccurs="0" />
                <xs:element name="HUISNUMMER" type="xs:decimal" 
minOccurs="0" />
                <xs:element name="TOEVOEGING" type="xs:string" 
minOccurs="0" />
                <xs:element name="PERCEELCOD" type="xs:string" 
minOccurs="0" />
                <xs:element name="PLAATS_NEN" type="xs:string" 
minOccurs="0" />
                <xs:element name="PLAATS_PTT" type="xs:string" 
minOccurs="0" />
                <xs:element name="GEMEENTE" type="xs:string" 
minOccurs="0" />
              </xs:sequence>
            </xs:complexType>
          </xs:element>
        </xs:choice>
      </xs:complexType>
    </xs:element>
  </xs:schema>
  <diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" 
xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
    <Bridgis_DataSet xmlns="">
      <Bridgis_DataTable diffgr:id="Bridgis_DataTable1" 
msdata:rowOrder="0" diffgr:hasChanges="inserted">
        <PSTK>3544AA</PSTK>
        <STRAAT_NEN>Zandweg                 </STRAAT_NEN>
        <STRAAT_PTT>ZANDWG           </STRAAT_PTT>
        <STRAAT_OFF>Zandweg                                    
</STRAAT_OFF>
        <HUISNUMMER>10</HUISNUMMER>
        <TOEVOEGING>      </TOEVOEGING>
        <PERCEELCOD>T</PERCEELCOD>
        <PLAATS_NEN>UTRECHT                 </PLAATS_NEN>
        <PLAATS_PTT>UTRECHT           </PLAATS_PTT>
        <GEMEENTE>UTRECHT                 </GEMEENTE>
      </Bridgis_DataTable>
      <Bridgis_DataTable diffgr:id="Bridgis_DataTable2" 
msdata:rowOrder="1" diffgr:hasChanges="inserted">
        <PSTK>3544AA</PSTK>
        <STRAAT_NEN>Zandweg                 </STRAAT_NEN>
        <STRAAT_PTT>ZANDWG           </STRAAT_PTT>
        <STRAAT_OFF>Zandweg                                    
</STRAAT_OFF>
        <HUISNUMMER>9</HUISNUMMER>
        <TOEVOEGING>      </TOEVOEGING>
        <PERCEELCOD>T</PERCEELCOD>
        <PLAATS_NEN>UTRECHT                 </PLAATS_NEN>
        <PLAATS_PTT>UTRECHT           </PLAATS_PTT>
        <GEMEENTE>UTRECHT                 </GEMEENTE>
      </Bridgis_DataTable>
    </Bridgis_DataSet>
  </diffgr:diffgram>
</DataSet>    

The number of records can be very large. I need to transform this to a tab-
separated text file within an ASP script. At the moment I go about this as 
follows (all code below is JScript):

---CODE---
strXML=String(rsXML(0));
oXMLDOM.loadXML(strXML);
oDatanodes=oXMLDOM.getElementsByTagName("Bridgis_DataTable");
strOut+=WriteRows(oDatanodes);
---END---

Where WriteRows is:

---CODE---
function WriteRows(oDataNodes) {
	strOut="";
	for(i=0;i<oDatanodes.length;i++) {
		nRecords++;
		aCh=new Array();
		oDatanode=oDatanodes.item(i);
		nChildren=oDatanode.childNodes.length;
		for(j=0;j<nChildren;j++) {
			oChild=oDatanode.childNodes.item(j);
			aCh.push(oChild.text);
		}
		strOut+=aCh.join("\t")+"\n";
	}
	return strOut;	
}
---END---

This is a very expensive operation which is not acceptable because the XML 
recordsets i get are very large (can be up to 1,000,000 records), so I am 
looking to implement a more efficient way to do this. I'm thinking about 
XSLT but don't know how I would integrate this into my ASP script. Any 
ideas?

Thanks,
Martijn


transparent
Print
Mail
Digg
delicious
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