Re: [xml] How to add datatypes



On Wed, Oct 20, 2010 at 9:08 PM, samaram s  wrote:
Hi,
I have a doubt :
wchar_t date[10];
wchar_t time[10];

(note: it's not a good idea to give your variable the same name as a
library function)


com1 = xmlNewDocComment(doc, BAD_CAST("Created on Date <date> and Time
<time> "));

I get my date and time in some Variables. I could not able to find how to
add the variable data in the comment?
Is there any %d and %s accepted ?

Yes, but not by libxml :)

wchar_t buffer[50];
wsprintf(buffer, L"Created on Date %s and Time %s ", date, time);

Now you need to convert buffer to UTF-8, because that's what libxml2 uses.

setlocale(LC_CTYPE, "UTF-8");
char buffer_utf8[200]; // 4x the original, just in case
wcstombs(buffer_utf8, buffer, 200 /* max bytes written */);

com1 = xmlNewDocComment(doc, buffer_utf8);

Also,
int Val = 01;
xmlNewProp(node, BAD_CAST "Token", BAD_CAST  <Val>);

How can i set the Value in there?

In this case, you can just pass the variable holding Val to xmlNewProp
(again, it should be UTF-8).

Csaba
-- 
GCS a+ e++ d- C++ ULS$ L+$ !E- W++ P+++$ w++$ tv+ b++ DI D++ 5++
Life is complex, with real and imaginary parts.
"Ok, it boots. Which means it must be bug-free and perfect. " -- Linus Torvalds
"People disagree with me. I just ignore them." -- Linus Torvalds



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]