Re: [xml] attribute and value element



Hallo David,

you could use the following:

/*------------------------------*/
int rc;

rc = xmlTextWriterStartElement(writer, BAD_CAST "elementname");
if(rc == -1)
{
        /*...error*/
}
rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "attr1", BAD_CAST "hello");
if(rc == -1)
{
        /*...error*/
}
rc = xmlTextWriterWriteString(writer, BAD_CAST "also a value here");
if(rc == -1)
{
        /*...error*/
}
rc = xmlTextWriterEndElement(writer);
if(rc == -1)
{
        /*...error*/
}
/*------------------------------*/

Remember that libxml2 expects the strings to be utf-8 encoded.

Servus -- Alfred
--
Alfred Mickautsch

Schuler Business Solutions AG
Karl-Berner-Str. 4
D-72285 Pfalzgrafenweiler
tel:    +49 (0)74 45 830-184
fax:    +49 (0)74 45 830-349
e-mail: alfred mickautsch schuler-ag com


-----UrsprÃngliche Nachricht-----
Von: xml-bounces gnome org [mailto:xml-bounces gnome org]Im 
Auftrag von
"David" 
Gesendet: Freitag, 17. November 2006 08:50
An: xml @ gnome. org
Betreff: [xml] attribute and value element


Hello,

I want to use the xmlwriter module from libxml2 and want to 
code that resuls in the following xml.

<elementname attr1="hello">also a value here</elementname>



I can produce the following xml, but i want to use value and 
attribute with one xml-tag.

<elementname attr1="hello">
 <value>also a value here</value>
</elementname>


I hope someone can help me.

Cheerz, David
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xml gnome org
http://mail.gnome.org/mailman/listinfo/xml



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