Re: [xml] problem reading attributes in XML with DTD



oliverst online de wrote:

I am trying to read the attributes in an XML with a DTD (http://www.breaken.de/temp/output.xml) and for soem reason I 
don't get the attributes with the node with xmlGetProp(). I read in the manual, that it does look for the #FIXED or 
default declarations unless DTD validation has been turned off. I have no DTD validation activated (I assume passing 0 
as the last parameter in xmlReadFile() truns it off) and I don't get anything from xmlGetProp(). If I look at the 
properties, I can clearly, that the first one is the one I am looking for ("name"). If I remove the DTD part 
in the XML it does parse it fine, but I don't want to remove, as this XML is automatically created.
You aren't getting anything because you are reading the DTD (still part of tree). The DTD is the first child of your doc. Use xmlDocGetRootElement to get your root.
xmlNodePtr root = xmlDocGetRootElement(doc);

Rob




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