Archived Forum Post

Index of archived forum posts

Question:

set attributes for elements

May 02 '13 at 09:26

<joblocation xsi:type="xsd:string">2321168</joblocation>

I am using xm23b->NewChild2("tns2:JobLocation",csLocationId); to create the xml, but I need to set the attribute for this element specifically as in the above example. Is there a way to do it?

Thanks


Answer

Call NewChild instead of NewChild2 so that the created XML child node is returned. Then set the attribute. In pseudo-code:

xChild = xm23b->NewChild("tns2:JobLocation",csLocationId);
xChild->AddAttribute("xsi:type","xsd:string");
delete xChild;   // (If C++)