Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
<?xml version="1.0" encoding="UTF-8"?>
<xml>
<doc>
<field3>def</field3>
<field1 attr1="123" attr2="456" attr3="789"/>
<field2>abc</field2>
</doc>
<doc>
<field2>abc</field2>
<field1 attr3="789" attr2="456" attr1="123" />
<field3>def</field3>
</doc>
<doc>
<field1 attr2="456" attr3="789" attr1="123" />
<field3>def</field3>
<field2>abc</field2>
<tags />
</doc>
</xml>
<?xml version="1.0" encoding="utf-8"?>
<doc>
<field1 attr1="123" attr2="456" attr3="789"/>
<field2>abc</field2>
<field3>def</field3>
</doc>
<doc>
<field1 attr1="123" attr2="456" attr3="789"/>
<field2>abc</field2>
<field3>def</field3>
</doc>
<doc>
<field1 attr1="123" attr2="456" attr3="789"/>
<field2>abc</field2>
<field3>def</field3>
<tags/>
</doc>
TEXT TO lcXML noshow
<?xml version="1.0" encoding="UTF-8"?>
<xml>
<DOC>
<field3>def</field3>
<field1 attr1="123" attr2="456" attr3="789"/>
<field2>abc</field2>
</DOC>
<DOC>
<field2>abc</field2>
<field1 attr3="789" attr2="456" attr1="123" />
<field3>def</field3>
</DOC>
<DOC>
<field1 attr2="456" attr3="789" attr1="123" />
<field3>def</field3>
<field2>abc</field2>
<tags />
</DOC>
</xml>
ENDTEXT
LOCAL oParser as MSXML2.DomDOCument
oParser = CreateObject( "MSXML2.DomDocument" )
oParser.loadXML(lcXML)
STRTOFILE(oParser.xml,AddBS(GetEnv("TEMP"))+"output.xml")
Mofiy File (AddBS(GetEnv("TEMP"))+"output.xml")
TEXT TO lcXML noshow
<?xml version="1.0" encoding="UTF-8"?>
<xml>
<DOC>
<field3>def</field3>
<field1 attr1="123" attr2="456" attr3="789"/>
<field2>abc</field2>
</DOC>
<DOC>
<field2>abc</field2>
<field1 attr3="789" attr2="456" attr1="123" />
<field3>def</field3>
</DOC>
<DOC>
<field1 attr2="456" attr3="789" attr1="123" />
<field3>def</field3>
<field2>abc</field2>
<tags />
</DOC>
</xml>
ENDTEXT
Local oParser As MSXML2.DomDOCument
oParser = Createobject( "MSXML2.DomDocument" )
oParser.LoadXML(lcXML)
Clear
outputxml(oParser)
Procedure outputxmlinfo()
Lparameters toNode, tnLevel
tnLevel = Evl(tnLevel,0)
? Space(tnLevel*3)+"node type:"+toNode.nodeTypeString+;
", node name:"+Evl(toNode.baseName,"NONE")+;
", node value:"+Nvl(toNode.nodeValue,"NONE")+;
", node attributes:"+Evl(outputattributes(toNode),"NONE")+;
", has child nodes:"+Iif(toNode.hasChildNodes,"Yes","No")
Try
For Each loNode In toNode.childNodes
outputxmlinfo(loNode, tnLevel+1)
Endfor
Catch
*
Endtry
Endproc
Procedure outputattributes
Lparameters toNode
lcAttributes = ""
Try
For Each loAttribute In toNode.Attributes
lcAttributes = lcAttributes +' '+ loAttribute.Name+'="'+loAttribute.Value+'"'
Endfor
Catch
*
Endtry
Return Evl(lcAttributes,"")
Endproc
TEXT TO lcXML noshow
<?xml version="1.0" encoding="UTF-8"?>
<xml>
<DOC>
<field3>def</field3>
<field1 attr1="123" attr2="456" attr3="789"/>
<field2>abc</field2>
</DOC>
<DOC>
<field2>abc</field2>
<field1 attr3="789" attr2="456" attr1="123" />
<field3>def</field3>
</DOC>
<DOC>
<field1 attr2="456" attr3="789" attr1="123" />
<field3>def</field3>
<field2>abc</field2>
<tags />
</DOC>
</xml>
ENDTEXT
Local oParser As MSXML2.DomDOCument
oParser = Createobject( "MSXML2.DomDocument" )
oParser.LoadXML(lcXML)
Clear
outputxml(oParser)
Procedure outputxml
Lparameters toNode, tnLevel
tnLevel = Evl(tnLevel,0)
Local llElement, llInstruction, lnCountChildnodes
lnCountChildnodes = 0
llInstruction = (toNode.nodeTypeString=="processinginstruction")
llElement = (toNode.nodeTypeString=="element")
IF llInstruction
?? "<?"+Lower(toNode.baseName)
Endif
If llElement
? Space(tnLevel*3)+"<"+Lower(toNode.baseName)+outputattributes(toNode)+">"
Endif
If !Empty(Nvl(toNode.nodeValue,""))
?? toNode.nodeValue
Else
lnCountChidnodes = 0
Try
For Each loNode In toNode.childNodes
lnCountChildnodes = lnCountChildnodes + 1
outputxml(loNode, tnLevel+1)
Endfor
Catch
*
Endtry
Endif
If llElement
If lnCountChildnodes>1
? Space(tnLevel*3)
Endif
?? "</"+Lower(toNode.baseName)+">"
Endif
If llInstruction
?? ">"
Endif
Endproc
Procedure outputattributes
Lparameters toNode
lcAttributes = ""
Try
For Each loAttribute In toNode.Attributes
lcAttributes = lcAttributes +' '+ loAttribute.Name+'="'+loAttribute.Value+'"'
Endfor
Catch
*
Endtry
Return Evl(lcAttributes,"")
Endproc
DO LOCFILE("xml-canonicalizer.prg")
m.Canon = CREATEOBJECT("XMLCanonicalizer")
? m.Canon.Canonicalize("[URL unfurl="true"]http://producthelp.sdl.com/sdl%20trados%20studio/client_en/sample.xml")[/URL]