(PureBasic) Xml.ChildContent Example #2
Another Xml.UpdateChildContent example...
IncludeFile "CkStringBuilder.pb"
IncludeFile "CkXml.pb"
Procedure ChilkatExample()
xml.i = CkXml::ckCreate()
If xml.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkXml::setCkTag(xml, "abc")
sbValue.i = CkStringBuilder::ckCreate()
If sbValue.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
i.i = 0
While i < 10
CkXml::setCkI(xml, i)
CkStringBuilder::ckClear(sbValue)
CkStringBuilder::ckAppendInt(sbValue,i)
CkXml::ckUpdateChildContent(xml,"xyz|test[i]",CkStringBuilder::ckGetAsString(sbValue))
i = i + 1
Wend
Debug CkXml::ckGetXml(xml)
; Output is:
; <?xml version="1.0" encoding="utf-8" ?>
; <abc>
; <xyz>
; <test>0</test>
; <test>1</test>
; <test>2</test>
; <test>3</test>
; <test>4</test>
; <test>5</test>
; <test>6</test>
; <test>7</test>
; <test>8</test>
; <test>9</test>
; </xyz>
; </abc>
CkXml::ckDispose(xml)
CkStringBuilder::ckDispose(sbValue)
ProcedureReturn
EndProcedure
|