HI chandini Presently xml Writer don’t have any
separate API to write namespace declaration attributes. It writes the namespace
declaration as a part of writing Elements and attributes by the APIs- xmlTextWriterWriteElementNS () / (xmlTextWriterStartElementNS
(), xmlTextWriterEndElement ())
xmlTextWriterWriteAttributeNS () / (xmlTextWriterStartAttributeNS
(), xmlTextWriterEndAttribute ()) respectively. For
example- Suppose I need to write the below xml data
<root
xmlns=”http://example.com/”> If I use the API xmlTextWriterStartElementNS () by passing Prefix-
NULL Name- “root” URI- “http://example.com/” Then when xmlTextWriterEndElement () is called for the above element it will write
the namespace declaration. <root
xmlns=”http://example.com/”> Now to write multiple namespace
declaration on one element you have to use the xmlTextWriterWriteAttribute ()/
API as described in below example Example – To write xmlns:ns1 = "urn:ietf:params:xml:ns:caldav"
you can pass xmlns:ns1 as name of
the attribute and the “"urn:ietf:params:xml:ns:caldav"
as value of the attribute to the API xmlTextWriterWriteAttribute(). Thanks
& Regards
Rabi Hello i am chandini. |