(PureBasic) Xml.UpdateAttrAt Example #2
Another Xml.UpdateAttrAt 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::ckUpdateAttrAt(xml,"xyz|test[i]",1,"index",CkStringBuilder::ckGetAsString(sbValue))
i = i + 1
Wend
Debug CkXml::ckGetXml(xml)
; Output is:
; <?xml version="1.0" encoding="utf-8" ?>
; <abc>
; <xyz>
; <test index="0" />
; <test index="1" />
; <test index="2" />
; <test index="3" />
; <test index="4" />
; <test index="5" />
; <test index="6" />
; <test index="7" />
; <test index="8" />
; <test index="9" />
; </xyz>
; </abc>
CkXml::ckDispose(xml)
CkStringBuilder::ckDispose(sbValue)
ProcedureReturn
EndProcedure
|