Re: [xml] xmlNewProp - Creating duplicate attributes in document

On Mon, Apr 30, 2007 at 11:04:55AM +0200, Trappel Martin wrote:

Normally I'm using xmlSetProp(..) to write properties, which works.

In one instance I've used xmlNewProp(..) and it seems that this function
leads to an invalid document tree ... ?

Consider this:
--- test.xml ---
<?xml version="1.0" encoding="UTF-8"?>
xmlDocPtr doc = xmlReadFile(fname, NULL, XML_PARSE_NOBLANKS);
xmlNodePtr root_element = xmlDocGetRootElement(doc);
if(XML_ELEMENT_NODE == root_element->type) {
  xmlAttrPtr newAttr1 = xmlNewProp(root_element, XMLCHARCAST("attrname"),
  xmlAttrPtr newAttr2 = xmlNewProp(root_element, XMLCHARCAST("attrname"),
xmlSaveFile(fname, doc);
--- test.xml ---
<?xml version="1.0" encoding="UTF-8"?>
<ROOT attrname="attrvalue" attrname="attrvalue"/>

Is this the intended behaviour of xmlNewProp(..)? (libxml2 2.18.0)

  Latest is 2.6.28, try with it, or at least provide a piece of code which
compiles by itself, such bugs were fixed in the past.


Red Hat Virtualization group
Daniel Veillard      | virtualization library
veillard redhat com  | libxml GNOME XML XSLT toolkit | Rpmfind RPM search engine

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