Page 1 of 1

Eport as XML

Posted: Fri Sep 16, 2011 11:09 am
by Venkat1688
Hi all,

Is it possible in TM1 to export data in XML format like we export as CSV ??

Re: Eport as XML

Posted: Fri Sep 16, 2011 11:43 am
by tomok
No, not natively. You would have to write your own code in TI to create the XML tags and use them in the TextOutput function.

Re: Eport as XML

Posted: Fri Sep 16, 2011 11:59 am
by Venkat1688
Thanks tomok.
Can i get a sample code or link where i can learn about it in detail. That would be great.

Re: Eport as XML

Posted: Fri Sep 16, 2011 12:45 pm
by tomok
Venkat1688 wrote:Thanks tomok.
Can i get a sample code or link where i can learn about it in detail. That would be great.
There isn't any that I know of. That's why I said you would have to write your own.

Re: Eport as XML

Posted: Sun Sep 18, 2011 11:28 pm
by rmackenzie

Code: Select all

# set empty string as quote char
DatasourceASCIIQuoteCharacter = '';

# set filename
sFileName = 'test.xml';

# header
sXml = '<?xml version="1.0" encoding="UTF-8"?>';
AsciiOutput ( sFileName, sXml );

# open root 
sXml = '<root>';
AsciiOutput ( sFileName, sXml );

# open branch
sXml = '<branch>';
AsciiOutput ( sFileName, sXml );

# populate some leaf information
nCounter = 1;
nMaxLeaves = 10;
WHILE ( nCounter <= nMaxLeaves );

  # open leaf
  sXml = '<leaf';
  sXml = sXml | ' name="' | NumberToString ( nCounter ) | '"';
  sXml = sXml | ' type="example">';

  # close leaf
  sXml = sXml | '</leaf>';

  # output
  AsciiOutput ( sFileName, sXml );
  nCounter = nCounter + 1;

END;

# close branch
sXml = '</branch>';
AsciiOutput ( sFileName, sXml );

# close root 
sXml = '</root>';
AsciiOutput ( sFileName, sXml );

Re: Eport as XML

Posted: Thu May 16, 2013 8:34 am
by iansdigby
Blessings upon rmackenzie for one of the most time-saving and useful snippets of code hertofore posted herein.

rmackenzie wrote:

Code: Select all

# set empty string as quote char
DatasourceASCIIQuoteCharacter = '';

# set filename
sFileName = 'test.xml';

# header
sXml = '<?xml version="1.0" encoding="UTF-8"?>';
AsciiOutput ( sFileName, sXml );

# open root 
sXml = '<root>';
AsciiOutput ( sFileName, sXml );

# open branch
sXml = '<branch>';
AsciiOutput ( sFileName, sXml );

# populate some leaf information
nCounter = 1;
nMaxLeaves = 10;
WHILE ( nCounter <= nMaxLeaves );

  # open leaf
  sXml = '<leaf';
  sXml = sXml | ' name="' | NumberToString ( nCounter ) | '"';
  sXml = sXml | ' type="example">';

  # close leaf
  sXml = sXml | '</leaf>';

  # output
  AsciiOutput ( sFileName, sXml );
  nCounter = nCounter + 1;

END;

# close branch
sXml = '</branch>';
AsciiOutput ( sFileName, sXml );

# close root 
sXml = '</root>';
AsciiOutput ( sFileName, sXml );