Sample code for 30+ languages & platforms
PowerBuilder

Using CDATA in XML

See more XML Examples

Demonstrates how to force the content of a node to be encapsulated in CDATA.

The output of the following program is an XML document that looks like this:


<root>
    <year>2009</year>
    <junk1>abc .. &lt; &amp; &gt; 123</junk1>
    <junk2><![CDATA[abc .. < & > 123]]></junk2>
</root>

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
oleobject loo_Xml
oleobject loo_Child1
oleobject loo_Child2
oleobject loo_Child3

loo_Xml = create oleobject
li_rc = loo_Xml.ConnectToNewObject("Chilkat.Xml")
if li_rc < 0 then
    destroy loo_Xml
    MessageBox("Error","Connecting to COM object failed")
    return
end if

loo_Xml.Tag = "root"

loo_Child1 = loo_Xml.NewChild("year","2009")

loo_Child2 = loo_Xml.NewChild("junk1","abc .. < & > 123")

loo_Child3 = loo_Xml.NewChild("junk2","abc .. < & > 123")
loo_Child3.Cdata = 1

destroy loo_Child1
destroy loo_Child2
destroy loo_Child3

Write-Debug loo_Xml.GetXml()


destroy loo_Xml