mibuso.com

Microsoft Business Solutions online community
It is currently Sun Dec 28, 2014 5:32 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Here is how to format XMLDOM output nicely
PostPosted: Tue Feb 15, 2011 11:49 am 
Offline

Joined: Tue Apr 11, 2006 9:00 pm
Posts: 1407
Location: Vienna
Country: Austria (at)
Gave me a hard time, so I thought I would share. If you don't do this, everything will be in one line...

Code: Select all

//Name   DataType   Subtype   Length
//Outs   OutStream      
//F   File      
//Reader   Automation   'Microsoft XML, v6.0'.SAXXMLReader60   
//Writer   Automation   'Microsoft XML, v6.0'.MXXMLWriter60   

F.QUERYREPLACE(FALSE);
F.CREATE(FileName);
F.CREATEOUTSTREAM(Outs);

IF ISCLEAR(Writer) THEN
   CREATE(Writer);

Writer.indent := TRUE;
Writer.standalone := FALSE;
Writer.omitXMLDeclaration := TRUE;
Writer.encoding := 'utf-8';

IF ISCLEAR(Reader) THEN
   CREATE(Reader);

Reader.contentHandler := Writer;
Reader.dtdHandler := Writer;   
Reader.errorHandler := Writer;

Reader.putProperty('http://xml.org/sax/properties/declaration-handler', Writer);
Reader.putProperty('http://xml.org/sax/properties/lexical-handler', Writer);

Reader.parse(PXMLDocOut);

PXMLDocOut.loadXML(Writer.output);

PXMLDocOut.save(Outs);
F.CLOSE;


Top
 Profile  
 
 Post subject: Re: Here is how to format XMLDOM output nicely
PostPosted: Tue Feb 15, 2011 12:34 pm 
Offline

Joined: Fri Mar 30, 2007 11:50 am
Posts: 216
Location: Nieuwe Niedorp
Country: Netherlands (nl)
Nice, I have once searched for a solution and did not find one!
Thanks for sharing!

_________________
Reijer Molenaar
Freelance NAV Developer
Object Manager
TVblik


Top
 Profile E-mail  
 
 Post subject: Re: Here is how to format XMLDOM output nicely
PostPosted: Wed Nov 05, 2014 10:58 pm 
Offline

Joined: Tue Nov 30, 1999 7:01 am
Posts: 94
Location: UmeƄ
Country: Sweden (se)
And here's the .Net equivalent:

Code: Select all
PROCEDURE SaveXMLFileOnClient@1000000006(XMLDoc@1000000000 : DotNet "'System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Xml.XmlDocument";Filename@1000000001 : Text[1024]);
    VAR
      ServerTempFileName@1000000002 : Text[250];
      Writer@1000000003 : DotNet "'System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Xml.XmlWriter";
      WriterSettings@1000000006 : DotNet "'System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Xml.XmlWriterSettings";
    BEGIN
      ServerTempFileName := ServTierMgt.ServerTempFileName('xml');
      WriterSettings := WriterSettings.XmlWriterSettings;
      WriterSettings.Indent := TRUE;
      WriterSettings.OmitXmlDeclaration := TRUE;
      Writer := Writer.Create(ServerTempFileName, WriterSettings);
      XMLDoc.Save(Writer);
      Writer.Close;
      ServTierMgt.DownloadToFile(ServerTempFileName, Filename);
    END;

_________________
Lars Westman
http://www.linkedin.com/in/larswestman


Top
 Profile E-mail WWW  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum


Search for:
Jump to: