cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
mary_v
Level 6

how to indent xml files with installscript

hi,

i managed to write xml files successfully using this post here

unfortunately the result is one huge line with elements etc.

is it possible to use xmltextwriter... or something similar to format the file with linebreaks, spaces etc? how would i achieve this?

any brief installscript example would be helpful

mary
Labels (1)
0 Kudos
(4) Replies
mary_v
Level 6

nobody any idea? :rolleyes:

mary
0 Kudos
Ajay_Ladsaria
Level 7

One idea would be to include a very small XSLT file with the xsl:output indent option set to yes in your setup. Then use a XML API to apply this XSLT file to your generated XML file to get the proper formatting.

You can probably find code samples of applying a XSLT to a XML document. And a sample of simple XSLT that you can use to correctly format the XML document.

Hope this helps,
Ajay
0 Kudos
mary_v
Level 6

yes you're right -
but i don't want to write a temporary xslt file if i don't have to ...

any other suggestion?

mary
0 Kudos
Marachkovski
Level 4

Dim xmlDocument
Dim pathToXmlFile

pathToXmlFile = Session.Property("INSTALLDIR") & "\InnovatorServerConfig.xml"
Set xmlDocument = CreateObject("Microsoft.XMLDOM")
xmlDocument.async = false
xmlDocument.load pathToXmlFile

Dim xslt
xslt = "" & vbcrlf
xslt = xslt & "" & vbcrlf
xslt = xslt & "" & vbcrlf
xslt = xslt & ""& vbcrlf
xslt = xslt & ""& vbcrlf
xslt = xslt & "
"

set xsltDom = CreateObject("Microsoft.XMLDOM")
xsltDom.async = false
xsltDom.loadXML(xslt)

' Apply transformation
xmlDocument.transformNodeToObject xsltDom, xmlDocument

xmlDocument.Save pathToXmlFile
0 Kudos