Note that there are some explanatory texts on larger screens.

plurals
  1. POXerces C++ - Load, read and save, alternatives?
    text
    copied!<p>I'm searching for a tutorial to load a XML file, read it, change it and finally save it with C++. I'm using Linux Ubuntu and tried to use Xerces. With Google and much time, I could only load an XML File:</p> <pre><code>#include &lt;xercesc/parsers/XercesDOMParser.hpp&gt; #include &lt;xercesc/dom/DOM.hpp&gt; #include &lt;xercesc/sax/HandlerBase.hpp&gt; #include &lt;xercesc/util/XMLString.hpp&gt; #include &lt;xercesc/util/PlatformUtils.hpp&gt; #include &lt;iostream&gt; using namespace std; using namespace xercesc; int main (int argc, char* args[]) { try { XMLPlatformUtils::Initialize(); } catch (const XMLException&amp; toCatch) { char* message = XMLString::transcode(toCatch.getMessage()); cout &lt;&lt; "Error during initialization! :\n" &lt;&lt; message &lt;&lt; "\n"; XMLString::release(&amp;message); return 1; } XercesDOMParser* parser = new XercesDOMParser(); parser-&gt;setValidationScheme(XercesDOMParser::Val_Always); parser-&gt;setDoNamespaces(true); // optional ErrorHandler* errHandler = (ErrorHandler*) new HandlerBase(); parser-&gt;setErrorHandler(errHandler); const char* xmlFile = "demo.xml"; try { parser-&gt;parse(xmlFile); } catch (const XMLException&amp; toCatch) { char* message = XMLString::transcode(toCatch.getMessage()); cout &lt;&lt; "Exception message is: \n" &lt;&lt; message &lt;&lt; "\n"; XMLString::release(&amp;message); return -1; } catch (const DOMException&amp; toCatch) { char* message = XMLString::transcode(toCatch.msg); cout &lt;&lt; "Exception message is: \n" &lt;&lt; message &lt;&lt; "\n"; XMLString::release(&amp;message); return -1; } catch (...) { cout &lt;&lt; "Unexpected Exception \n" ; return -1; } DOMNode* docRootNode; // DOMNode* aNode; DOMDocument* doc; doc = parser-&gt;getDocument(); docRootNode = doc-&gt;getDocumentElement(); cout &lt;&lt; docRootNode-&gt;getAttributes() &lt;&lt; endl; //returns Hex delete parser; delete errHandler; return 0; } </code></pre> <p>How do I can read an manipulate the XML file and finally save it? Is there alternative libraries? (I tried tinyxml but the files returns errors, when I want to compile it)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload