Re: [xml] Get text content of an element which surrounds another element
- From: Nikolay Sivov <bunglehead gmail com>
- To: Bogdan Cristea <cristeab gmail com>, libXml <xml gnome org>
- Subject: Re: [xml] Get text content of an element which surrounds another element
- Date: Sun, 20 Oct 2013 20:53:48 +0400
On 10/20/2013 19:13, Bogdan Cristea wrote:
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.
Well, that's not surprising. 'h1' in your example contains 3 children -
text, element, text - in that order. So when you request node->children
you get first child which is a text node, its content is in 'content'
field. I don't see a problem here.
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 ?
It looks wrong to use a node pointer returned from previous reader
iteration. As I understand it could be reused, and previous node is
freed when you're done with it. So in your example you store previous
element pointer which is 'img' and later try to use it to get some text
(which can't be outside of 'img' scope by the way)? Are you sure
xmlTextReaderCurrentNode() doesn't return anything for text node?
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]