[xml] Can I read namespace URIs as regular attributes?
- From: Jianqing Zhang <arrow jianqing gmail com>
- To: xml gnome org
- Subject: [xml] Can I read namespace URIs as regular attributes?
- Date: Tue, 1 Sep 2009 22:30:37 -0500
I'm trying to read all namespace URIs by go through all attributes of
the root element. Can I read them as regular attributes?
My code is following:
....
// Current node is the root element
attrNum = xmlTextReaderAttributeCount(reader);
for (i=0;i<attrNum;i++){
xmlChar *name, *value;
assert(xmlTextReaderMoveToAttributeNo(reader,i)==1);
name = xmlTextReaderName(reader);
value = xmlTextReaderGetAttributeNo(reader,i); // read by index
//value = xmlTextReaderGetAttribute(reader,name); // or read by name
if (xmlTextReaderIsNamespaceDecl(reader))
cout << "it is a ns decl" << endl; // It always shows it is
namespace declaration.
// Name always can be read correctly
if (name == NULL)
cout << "name is null" << endl;
else
cout << "name is " << name << endl;
// However, value is always null no matter index or name is used.
if (value == NULL)
cout << "value is null" << endl;
else
cout << "value is " << value << endl;
...
}
Although names are always read correctly, I always get NULL for
values. Do I missing something?
Thanks
[Date Prev][
Date Next] [Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]