At 07.14 24/08/2006 -0700, fatboyjim wrote:
Alberto Massari wrote:
>
> At 04.06 24/08/2006 -0700, fatboyjim wrote:
>
>>Using the DOM API, I can successfully add attributes to a node using the
>>following:
>>
>>XMLCh *name = XMLString::transcode("Age");
>>XMLCh *value = XMLString::transcode("Twelve");
>>element->setAttribute(name, value);
>>
>>However, what if I have my value held in an integer?
>>XMLCh *name = XMLString::transcode("Age");
>>int age = 12;
>>...
>>...
>>
>>How do I go from here? I don't want to use itoa() to convert integer to
>>ascii
>
> Hi Jim,
> you have to provide a textual representation of the number; if you
> don't want to use the C runtime functions, you can always use
> XMLString::binToText
>
> Hope this helps,
> Alberto
>
>
>
Thanks for that Alberto,
One more thing though, how do I go about assigning memory to the XMLCh *
that is a parameter for the binToText method?
Hi Jim,
given that you are going to use that memory to create a DOMAttr (that
will make a copy of it) you can use a stack-based buffer.
E.g.
XMLCh buff[20];
XMLString::binToText(12, buff, 19, 10);
element->setAttribute(name, buff);
Hope this helps,
Alberto
Transcode usually allocates memoy for me so I'm not sure how to do it
manually
Thanks again
Jim
--
View this message in context:
http://www.nabble.com/setDOMAttribute-using-integer-value-tf2158015.html#a5964758
Sent from the Xerces - C - Users forum at Nabble.com.