(C) Xml.UpdateAttrAt Example #2
Another Xml.UpdateAttrAt example...
#include <C_CkXml.h>
#include <C_CkStringBuilder.h>
void ChilkatSample(void)
{
HCkXml xml;
HCkStringBuilder sbValue;
int i;
xml = CkXml_Create();
CkXml_putTag(xml,"abc");
sbValue = CkStringBuilder_Create();
i = 0;
while (i < 10) {
CkXml_putI(xml,i);
CkStringBuilder_Clear(sbValue);
CkStringBuilder_AppendInt(sbValue,i);
CkXml_UpdateAttrAt(xml,"xyz|test[i]",TRUE,"index",CkStringBuilder_getAsString(sbValue));
i = i + 1;
}
printf("%s\n",CkXml_getXml(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_Dispose(xml);
CkStringBuilder_Dispose(sbValue);
}
|