Re: [libxml++] NodeList problem.
- From: Darko Miletic <darko uvcms com>
- To: Jonathan Wakely <cow compsoc man ac uk>
- Cc: libxmlplusplus-general lists sourceforge net
- Subject: Re: [libxml++] NodeList problem.
- Date: Thu, 09 Jun 2005 13:53:03 -0300
Jonathan Wakely wrote:
Surely not?!?!
If the container is empty calling begin() will return an iterator that
compares equal to end(). _dereferencing_ that iterator would be an
error, but not simply copying it.
It will be error if you use (as you did) reference to NodeList. You
wrote the code like this:
const xmlpp::Node::NodeList& m_nodeList = root->get_children();
that means that you take reference to the temporary created nodelist
object. It is invalid after that line is executed an hence the access
violation. Therefore you need to copy it. Instead of const
xmlpp::Node::NodeList& use just xmlpp::Node::NodeList that way the list
will be copied as it should because the declaration of
xmlpp::Node::get_children is like this:
NodeList get_children(const std::string& name = std::string());
So no reference is returned here.
The code should be like this:
xmlpp::Node::NodeList m_nodeList = root->get_children();
xmlpp::Node::NodeList::const_iterator itr = m_nodeList.begin();
Darko
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]