"Re: [xml] how to write a xmlAttr with xmlTextWriter?"



Hi,

on 2/10/2004 2:23 PM Kasimier Buchcik wrote:

Hi,

does there exist a function that can serialize the content of a xmlAttr 
(attr->children) to be used with "xmlTextWriterWriteAttribute"? It 
should bear analogy to "xmlAttrSerializeContent" which is used by the 
serialization mechanism internally. If no, did someone already succeded 
in xml-text-writing an xmlAttr?


Hmm, I tried the following combination but it does not behave properly:

attrVal = xmlNodeListGetString(NULL, attr->children, 0);
xmlTextWriterWriteAttribute(writer, attr->name, attrVal);

Since "xmlNodeListGetString" and "xmlTextWriterWriteAttribute" both lead 
to a "&" to "&" conversion, I get a recursive conversion if cycling 
serialization & parsing:

"<" --> "&amp;lt;" --> "&amp;amp;lt;" --> etc.

Entity references will be mangled by xmlTextWriterWriteAttribute.
Is there any chance of adding to "xmlAttrSerializeTxtContent" (called by 
"xmlTextWriterWriteAttribute") a heuristic evaluation if a "&" is a 
beginning of an entity reference or not? But maby this does not fit in 
the big picture. Any other clues?


Regards,

Kasimier




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