(C) Xml.ChildContent Example #2
Another Xml.UpdateChildContent 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_UpdateChildContent(xml,"xyz|test[i]",CkStringBuilder_getAsString(sbValue));
i = i + 1;
}
printf("%s\n",CkXml_getXml(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_Dispose(xml);
CkStringBuilder_Dispose(sbValue);
}
|