Hi
I would like to take the text content of <h1> element in the example below:
<h1>Image follows<img id="rId51" src="image1.jpg" alt="WikiHow Logo"
smilref="speechgen0002.smil#tcp7" />after imge</h1>
I am using xmlTextReader, but I can get only the text before the image.
Here is the basic code I use:
while (1 == xmlTextReaderRead(reader)) {
switch (xmlTextReaderNodeType(reader)) {
case XML_READER_TYPE_ELEMENT:
name = xmlTextReaderConstName(reader);
if (NULL != name) {
cout << "Name: " << (const char*)name << endl;
}
node = xmlTextReaderCurrentNode(reader);
if (1 == xmlTextReaderHasAttributes(reader)) {
if (NULL != node) {
xmlAttr* attr = node->properties;
while (attr) {
cout << (const char*)attr->name << " = " <<
(const char*)attr->children->content << endl;
attr = attr->next;
}
} else {
cout << "NULL node with attrs" << endl;
}
}
break;
case XML_READER_TYPE_TEXT:
if (NULL != node && (NULL != node->children) && (NULL !=
node->children->content)) {
cout << "Content: " << (const
char*)node->children->content << endl;
}
break;
}
}
First, I am puzzled by the way I can obtain the text contained by h1
element. I am using the node from a previous xmlTextReaderRead() call.
If I try to obtain the current node in XML_READER_TYPE_TEXT case the
node pointer is NULL.
Second, I don't know how to obtain the text after <img> element which
still belongs to <h1> element. s there a way to do so ?
thanks
Bogdan
_______________________________________________
xml mailing list, project page http://xmlsoft.org/
xml@gnome.org
https://mail.gnome.org/mailman/listinfo/xml