Re: [xml] How to add datatypes
- From: samaram s <samaram007 gmail com>
- To: Csaba Raduly <rcsaba gmail com>
- Cc: xml gnome org
- Subject: Re: [xml] How to add datatypes
- Date: Thu, 21 Oct 2010 11:24:45 -0400
Thank you so much.
But when i tried as you said, it says 2nd argument should be xmlchar* type not char* . when i type casted it, it doesn't like it.
Any idea?
On Thu, Oct 21, 2010 at 3:14 AM, Csaba Raduly
<rcsaba gmail com> wrote:
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]