Re: [xml] xml API to add attribute
- From: Age Jan Kuperus <AgeJan Kuperus wur nl>
- To: xml gnome org
- Subject: Re: [xml] xml API to add attribute
- Date: Wed, 13 Oct 2010 19:09:21 +0200
On 13/10/10 16:34, samaram s wrote:
Hi,
I am new to libxml group. I chose this because it is very popular one.Please give us your support to complete
my understanding of libxml2.
A .
I would like to generate script something like below,
<Option Value="00">English</Option>
<Option Value="01">French</Option>
B.
But when i am doing like below,
node1 = xmlNewChild(node, NULL, BAD_CAST "Option", NULL);
node2 = xmlNewText(BAD_CAST "Value= 00[English]");
xmlAddChild(node1,node2);
xmlAddChild(node, node1);
I get like ,
<Option>Value= 00[English]</Option>
<Option>Value= 01[French]</Option>
Is there a way to do like shown in A. Which API should i use to do so?
Please give me some idea.
Thanks,
Sam
read the doc and you will find http://xmlsoft.org/html/libxml-tree.html#xmlNewProp as the
function to add an attribute like "Value":
attr = xmlNewProp (node1, BAD_CAST "Value", BAD_CAST "00");
and your text node shoud be just " English":
node2 = xmlNewText(BAD_CAST "English");
--
with kind regards,
Age Jan Kuperus
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]