tinyxml

What memory management do I need to cleanup when using TinyXml for C++?

混江龙づ霸主 提交于 2019-12-19 19:17:22
问题 I'm doing the following with TinyXml: TiXmlDocument doc; TiXmlDeclaration* decl = new TiXmlDeclaration( "1.0", "", "" ); TiXmlElement* main = new TiXmlElement("main"); TiXmlElement* header = new TiXmlElement("header"); header->SetAttribute("attribute","somevalue"); main->LinkEndChild(header); // ... Add many more TiXmlElment* to other elements all within "main" element doc.LinkEndChild(decl); doc.LinkEndChild(main); // ... do stuff with doc // Now I am done with my doc. What memory management

Compiling libraries with CMake under Cygwin

那年仲夏 提交于 2019-12-12 18:18:18
问题 I have been trying to compile TinyXML using CMake as a sort of mini project, trying to learn CMake. As an addition I am trying to make it compile into a dynamic library and install itself so it works. So far I have managed to get it to compile and install BUT it compiles into a .dll and a .dll.a and the only way to get it to work is to have it install into both /bin and /lib, which makes it install both files in both folders. This setup works but I'm guessing the .dll should be in /bin and

TinyXML: Save document to char * or string

喜你入骨 提交于 2019-12-12 09:31:59
问题 I'm attempting to use TinyXML to read and save from memory, instead of only reading and saving files to disk. It seems that the documnent's parse function can load a char *. But then I need to save the document to a char * when I'm done with it. Does anyone know about this? Edit: The printing & streaming functions aren't what I'm looking for. They output in a viewable format, I need the actual xml content. Edit: Printing is cool. 回答1: I'm not familiar with TinyXML, but from the documentation

tinyXml how to add an element

痴心易碎 提交于 2019-12-11 16:54:49
问题 I have the following: TiXmlDocument doc; TiXmlDeclaration * decl = new TiXmlDeclaration( "1.0", "utf-8", ""); doc.LinkEndChild( decl ); TiXmlElement * root = new TiXmlElement( "Value" ); TiXmlElement * element = new TiXmlElement( "number" ); root->LinkEndChild( element); TiXmlText * text = new TiXmlText( "5" ); element->LinkEndChild( text ); IT IS OK LIKE THIS? I WOULD LIKE TO HAVE the .xml like: <Value> <number>5</number> </Value> THX! my question is if i can have a int value as a string. if

How to load XML document from `std::istream`?

﹥>﹥吖頭↗ 提交于 2019-12-11 13:40:02
问题 I'd like to load TinyXml documents from std::istream , but it doesn't contain such method: /** Load a file using the current document value. Returns true if successful. Will delete any existing document data before loading. */ bool LoadFile( TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); /// Save a file using the current document value. Returns true if successful. bool SaveFile() const; /// Load a file using the given filename. Returns true if successful. bool LoadFile( const char *

how to obtain the value from an xml tag using FirstCHildElement

╄→尐↘猪︶ㄣ 提交于 2019-12-11 07:50:08
问题 I am working in C++. I would like to ask how to obtain the value text from: <message> text </message> I have TiXmlHandle handle(&doc); TiXmlElement* section; section=doc.FirstChildElement("message"); How to do it from now on? I know I have to work with .Element() but I don't know how. 回答1: You can use the function GetText() to obtain the contents of <message> . I put your XML-contents in a file called dummy.xml and used the following code to print the contents: TiXmlDocument doc("dummy.xml");

Can't include TinyXML in C++/CLI project

醉酒当歌 提交于 2019-12-11 07:27:39
问题 I have a C++/CLI project, and I want to include TinyXML. I downloaded the library, added it as a a new project to my solution and added a reference from my project to the library. In my code I have #include "StdAfx.h" #include "tinyxml.h" When i compile i get 70 linking errors. I tried to comment #define TIXML_SAFE in tinyxml.h ( saw that on google ) , but doesnt work. Thanks, Dave 回答1: Got it, i included tinyxml in a subfolder of my current project, instead of adding it in its own project. I

TinyXML and preserving HTML Entities

孤街醉人 提交于 2019-12-11 06:25:59
问题 I'm using TinyXml to parse some XML that has some HTML Entities embedded in text nodes. I realize that TinyXML is just an XML parser, so I don't expect or even want TinyXML to do anything to the entities. In fact I want it to leave them alone. If I have some XML like this: ... <blah>ü</blah> ... Calling Value() on the TiXmlText instance I get: "uuml;" So TinyXml always seems to remove the ampersand. Is there any way I can get it to leave it alone so it comes out unchanged? Appreciate any

Parsing <multi_path literal=“not_measured”/> in TinyXML

痴心易碎 提交于 2019-12-11 03:58:32
问题 How do I parse the following in TinyXML: <multi_path literal="not_measured"/> I am able to easily parse the below line: <hello>1234</hello> The problem is that the first statement is not getting parsed the normal way. Please suggest how to go about this. 回答1: Not 100% sure what youre question is asking but here is a basic format too loop through XML files using tinyXML: /*XML format typically goes like this: <Value atribute = 'attributeName' > Text </value> */ TiXmlDocument doc("document.xml"

TinyXML - any way to skip problematic DOCTYPE tag?

我只是一个虾纸丫 提交于 2019-12-11 02:21:36
问题 I am using TinyXML2 to parse an XML that looks somewhat like: <?xml version="1.0" encoding="US-ASCII"?> <!DOCTYPE comp PUBLIC "-//JWS//DTD xyz//EN" "file:/documentum/xyz.dtd" [<!ENTITY subject SYSTEM "dctm://he/abc"> ]> <comp> ... </comp> Unfortunately, as per http://www.grinninglizard.com/tinyxmldocs/, it looks like TinyXML doesn't support parsing DOCTYPE tags such as the one in the above sample. I am not interested in the DTD per se and would only like to parse the rest of the XML (starting