Comments (3)
Isn't that because the doc has already been destructed? If you make the
doc a member of the class so it has not been freed, it will work.
Change the class to:
class myxmltool
{
public:
string filename;
xml_node root;
xml_document doc;
myxmltool(string fname)
{
doc.load_file(fname.c_str());
root = xml_node(doc.root()); //root is created and has contents
}
};
jima
On Fri, Dec 4, 2015 at 8:39 AM, changshen [email protected] wrote:
class myxmltool
{
public:
string filename;
xml_node root;
myxmltool(string fname)
{
xml_document doc;
doc.load_file(fname.c_str());
root = xml_node(doc.root()); //root is created and has contents
}};
void main()
{
myxmltool tool = myxmltool("c:\myxmlfile.xml");
xml_node rootnode = tool.root; //root was not there. it was distroyed
already}
—
Reply to this email directly or view it on GitHub
#71.
from pugixml.
xml_document object controls the lifetime of the tree; xml_node objects are just handles to nodes of that tree. Destroying the xml_document object leads to the entire tree being destroyed; it's invalid to use the nodes from the tree after that. This is described in more detail in this section of the manual: http://pugixml.org/docs/manual.html#dom.cpp.
from pugixml.
Thanks zeux and jima
I thought of this and tried to have xml_document as a member of extended class. But compiler complained :
Error 2 error C2248: 'pugi::xml_document::xml_document' : cannot access private member declared in class 'pugi::xml_document'
even with empty constructor
myxmltool(string fname){}
from pugixml.
Related Issues (20)
- Version 1.14 HOT 1
- Can you add the ability to access child nodes using index? HOT 1
- PUGIXML_WCHAR_MODE and error messages. HOT 1
- add xml_node_type_str function for debugging and application logging HOT 3
- option to join multiple CDATA sections into one when parsing HOT 2
- parse_embed_pcdata and parse_merge_pcdata don't play together HOT 2
- Unexpected #endif in line 13201 with precompilation in a pch.h file HOT 2
- XML Canonicalization: as an option, allow parsing eol's into the document model (as PCDATA holding those) HOT 2
- Warning when building 1.14 in x86 on Clang HOT 3
- Position of the parse result offset in case of status_bad_start_element
- Error in handling loading errors example HOT 1
- Incorrect result of xml_document::load_file -"File was not found" HOT 2
- Question: I have made my own case insensitive version, is that ok? HOT 2
- Serilisation HOT 4
- pugi::xml_node and std::ranges, maybe a documentation request HOT 2
- call function xml_node::empty() always return false in anyway HOT 3
- Not able to attach a xsl via a `<?xml-stylesheet ...?>` node HOT 1
- xmldocument::save uses non-transformed encoding parameter HOT 4
- Warnings (C5245) when having PUGIXML_NO_STL and PUGIXML_API defined HOT 6
- PUGIXML_WCHAR_MODE featrue for vcpkg HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pugixml.