Create your own XML structure

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Create your own XML structure

Tolis Linardis
Dear all,

 is it possible to create your own XML structure through the functions
    CreateXMLOutput, GetXmlUtf16 ?

For example GetXmlUtf16 creates the following:

<category label="TV" number="3" text="TV" varName="view">
 <dimension axis="column" text="Statistics">
   <category text="Frequency">
       <cell number="61" text="61" />
  </category>
   <category text="Percent">
       <cell decimals="1" number="27.111111111111" text="27,1" />
  </category>
  <category text="Valid Percent">
       <cell decimals="1" number="27.232142857143" text="27,2" />
  </category>
  <category text="Cumulative Percent">
       <cell decimals="1" number="100" text="100,0" />
  </category>
</dimension>

</category>


bbut we'd also like to have the following:

<category label="TV" number="3" text="TV" varName="view">
   <Frequency>61 </Frequency>
   <Percent> 27.111111111111 </Percent>
   <Valid Percent>27.232142857143</Valid Percent>
   <Cumulative Percent>100</Cumulative Percent>
</category>


Is it possible?



Many Thanks.

 Tolis Linardis
Reply | Threaded
Open this post in threaded view
|

Re: Create your own XML structure

Peck, Jon
Using the Python tools, you can create any XML output you want, but you have to do it by building the XML yourself.  There are several ways to go about this.

As part of the standard Python library, there are XML.SAX api tools that can read and parse the XML and then help you write a new XML document.  You can find an example that uses this in the DisplayDict.py module on SPSS Developer Central (www.spss.com/devcentral) in the Downloads section.

There are several other XML modules in the Python standard library that build a full DOM or a mini-DOM that you can manipulate.  xml.dom and xml.minidom are two of them.

There is a third party module called ElementTree that you can download and that provides very nice tools for working with XML in general.  (A variation of this module has been added to the Python standard library in 2.5 under the name xml.etree.ElementTree.  You can't use that with SPSS yet, since SPSS uses Python 2.4 currently).

Or, you could save the XML as a file and use an XSLT processor to transform the XML into your new format.  You likely have the Microsoft XML processor msxslt already on your system, and there are many others freely downloadable.

So it all depends on which technology you or your colleagues are most comfortable with.

HTH,
Jon Peck
SPSS

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Tolis Linardis
Sent: Wednesday, April 04, 2007 2:31 AM
To: [hidden email]
Subject: [SPSSX-L] Create your own XML structure

Dear all,

 is it possible to create your own XML structure through the functions
    CreateXMLOutput, GetXmlUtf16 ?

For example GetXmlUtf16 creates the following:

<category label="TV" number="3" text="TV" varName="view">
 <dimension axis="column" text="Statistics">
   <category text="Frequency">
       <cell number="61" text="61" />
  </category>
   <category text="Percent">
       <cell decimals="1" number="27.111111111111" text="27,1" />
  </category>
  <category text="Valid Percent">
       <cell decimals="1" number="27.232142857143" text="27,2" />
  </category>
  <category text="Cumulative Percent">
       <cell decimals="1" number="100" text="100,0" />
  </category>
</dimension>

</category>


bbut we'd also like to have the following:

<category label="TV" number="3" text="TV" varName="view">
   <Frequency>61 </Frequency>
   <Percent> 27.111111111111 </Percent>
   <Valid Percent>27.232142857143</Valid Percent>
   <Cumulative Percent>100</Cumulative Percent>
</category>


Is it possible?



Many Thanks.

 Tolis Linardis