Re: [xml] xmlNewProp - Creating duplicate attributes in document
- From: Daniel Veillard <veillard redhat com>
- To: Trappel Martin <martin trappel ksengineers at>
- Cc: xml gnome org
- Subject: Re: [xml] xmlNewProp - Creating duplicate attributes in document
- Date: Wed, 2 May 2007 12:50:09 -0400
On Mon, Apr 30, 2007 at 11:04:55AM +0200, Trappel Martin wrote:
Hello!
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"?>
<ROOT/>
---
****
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"),
XMLCHARCAST("attrvalue"));
xmlAttrPtr newAttr2 = xmlNewProp(root_element, XMLCHARCAST("attrname"),
XMLCHARCAST("attrvalue"));
}
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.
Daniel
--
Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard | virtualization library http://libvirt.org/
veillard redhat com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]