<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Anwendung: verwirrender Fehler bei XML - Datei]]></title><description><![CDATA[<p>Hallo!</p>
<p>Zuerst schonmal:<br />
Ja, ich habe die FAQ gelesen, und die Borland Hilfe und TROTZDEM hänge ich seit 2 Tagen über dem Problem:<br />
Ich möchte einige Einstellungen aus meinem Programm in eine XML Datei speichern. Diese wird bei Bedarf, wenn sie noch nicht existiert, erstellt.<br />
Klappt auch alles.<br />
Dann übergebe ich meiner XML-Funktion einen String, z.b.: &quot;Hallo\\das\\ist\\ein\\test&quot;. In der XML Datei soll dann dies stehen:</p>
<pre><code>&lt;Hallo&gt;
   &lt;das&gt;
      &lt;ist&gt;
        ....
           &lt;Eintrag1&gt;1&lt;/Eintrag1&gt;
           &lt;Eintrag2&gt;1&lt;/Eintrag2&gt;
           &lt;Eintrag3&gt;1&lt;/Eintrag3&gt;
        .... 
      &lt;/ist&gt;
   &lt;/das&gt;
&lt;/Hallo&gt;
</code></pre>
<p>Das macht er auch...ABER..<br />
wenn ich nun Werte einfügen will, dann Schreibt er die Einträge hintereinander, nicht untereinander (d.h. er schreibt kein newline in die XML Datei).</p>
<pre><code>&lt;Hallo&gt;
   &lt;das&gt;
      &lt;ist&gt;
        ....
           &lt;Eintrag1&gt;1&lt;/Eintrag1&gt;&lt;Eintrag2&gt;1&lt;/Eintrag2&gt;&lt;Eintrag3&gt;1&lt;/Eintrag3&gt;
        .... 
      &lt;/ist&gt;
   &lt;/das&gt;
&lt;/Hallo&gt;
</code></pre>
<p>Das heißt ja im Prinzip, dass irgendwo im Code ein Fehler ist.<br />
Hier der Copy-Paste Code zum selber Probieren:</p>
<p>Ich würde mich über eine Rückmeldung freuen!</p>
<p>XML.cpp:</p>
<pre><code class="language-cpp">#include &lt;vcl.h&gt;
#include &lt;string&gt;
#pragma hdrstop

#include &quot;XML.hpp&quot;

using namespace std;

//---------------------------------------------------------------------------
// XML - Datei speichern / anlegen
//---------------------------------------------------------------------------
bool SaveXMLOption(string FileName, string XMLString, string ChildContent)
{
int count=GetXMLNote(XMLString,0).count;
_di_IXMLNode tempKnoten1,tempKnoten2;

NoteInfoStrukt tempNoteInfo =GetXMLNote(XMLString,1);

if(XMLString==&quot;&quot;)  // XMLString darf nicht leer sein
return false;

 if(FileExists(FileName.c_str()))
  {
    try
    {
       _di_IXMLDocument XMLDocument = LoadXMLDocument(FileName.c_str());
      XMLDocument-&gt;Active = true;
      tempKnoten1 = XMLDocument-&gt;DocumentElement;
    for(int i=2;i&lt;count;i++)
   {
   if(i%2)
   {
    if(tempKnoten2-&gt;ChildNodes-&gt;FindNode((tempNoteInfo = GetXMLNote(XMLString,i)).Node.c_str())==NULL)
    tempKnoten1 = tempKnoten2-&gt;AddChild(tempNoteInfo.Node.c_str());
    else
    tempKnoten1 =  tempKnoten2-&gt;ChildNodes-&gt;FindNode((tempNoteInfo = GetXMLNote(XMLString,i)).Node.c_str());
      }
   else
    {
    if(tempKnoten1-&gt;ChildNodes-&gt;FindNode((tempNoteInfo = GetXMLNote(XMLString,i)).Node.c_str())==NULL)
    tempKnoten2 = tempKnoten1-&gt;AddChild((tempNoteInfo =GetXMLNote(XMLString,i)).Node.c_str());
    else
      tempKnoten2 =  tempKnoten1-&gt;ChildNodes-&gt;FindNode((tempNoteInfo = GetXMLNote(XMLString,i)).Node.c_str());
      }
   }
   if(count%2)
   if(tempKnoten2-&gt;ChildNodes-&gt;FindNode((tempNoteInfo = GetXMLNote(XMLString,count)).Node.c_str())!=NULL)
    tempKnoten2-&gt;ChildNodes-&gt;Delete((tempNoteInfo = GetXMLNote(XMLString,count)).Node.c_str());
   else
   if(tempKnoten1-&gt;ChildNodes-&gt;FindNode((tempNoteInfo = GetXMLNote(XMLString,count)).Node.c_str())!=NULL)
    tempKnoten1-&gt;ChildNodes-&gt;Delete((tempNoteInfo = GetXMLNote(XMLString,count)).Node.c_str());

   _di_IXMLNode Node = XMLDocument-&gt;CreateElement((tempNoteInfo =GetXMLNote(XMLString,count)).Node.c_str(), L&quot;&quot;);
   Node-&gt;NodeValue = WideString(ChildContent.c_str());
   if(count%2)
    tempKnoten2-&gt;ChildNodes-&gt;Add(Node);
   else
    tempKnoten1-&gt;ChildNodes-&gt;Add(Node);

    // XML Dokument in eine Datei abspeichern
    XMLDocument-&gt;FileName=FileName.c_str();
    XMLDocument-&gt;SaveToFile(XMLDocument-&gt;FileName);
  }
    catch (...){
  return false; }

  return true;
  }
  else
  {
   try
    {

TXMLDocument *XMLDocument = new TXMLDocument(&quot;&quot;); // WICHTIG: kein Datei Namen übergeben, sonst Exception

XMLDocument-&gt;Options = XMLDocument-&gt;Options &lt;&lt; doNodeAutoIndent;  // für die richtige Formatierung
XMLDocument-&gt;Active = true;
XMLDocument-&gt;Encoding = &quot;UTF-16&quot;;    // Encoding festlegen, damit auch z.B. Umlauten richtig rüberkommen
XMLDocument-&gt;FileName=FileName.c_str();

tempKnoten1 = XMLDocument-&gt;CreateElement((tempNoteInfo =GetXMLNote(XMLString,1)).Node.c_str(), &quot;&quot;);
XMLDocument-&gt;DocumentElement = tempKnoten1;

   for(int i=2;i&lt;count;i++)
   {
   if(i%2)
    if(tempKnoten2-&gt;ChildNodes-&gt;FindNode((tempNoteInfo = GetXMLNote(XMLString,i)).Node.c_str())==NULL)
    tempKnoten1 = tempKnoten2-&gt;AddChild(tempNoteInfo.Node.c_str());
    else
      tempKnoten1 =  tempKnoten2-&gt;ChildNodes-&gt;FindNode((tempNoteInfo = GetXMLNote(XMLString,i)).Node.c_str());
   else
    if(tempKnoten1-&gt;ChildNodes-&gt;FindNode((tempNoteInfo = GetXMLNote(XMLString,i)).Node.c_str())==NULL)
    tempKnoten2 = tempKnoten1-&gt;AddChild((tempNoteInfo =GetXMLNote(XMLString,i)).Node.c_str());
    else
      tempKnoten2 =  tempKnoten1-&gt;ChildNodes-&gt;FindNode((tempNoteInfo = GetXMLNote(XMLString,i)).Node.c_str());
   }
   _di_IXMLNode Node = XMLDocument-&gt;CreateElement((tempNoteInfo =GetXMLNote(XMLString,count)).Node.c_str(), L&quot;&quot;);
   Node-&gt;NodeValue = WideString(ChildContent.c_str());
   if(count%2)
    tempKnoten2-&gt;ChildNodes-&gt;Add(Node);
    else
    tempKnoten1-&gt;ChildNodes-&gt;Add(Node);

    // XML Dokument in eine Datei abspeichern
    XMLDocument-&gt;SaveToFile();
  }
  catch (...)
  {
   return false;
  }

  return true;
  }
}
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
// XML - Knoten rausfiltern
//---------------------------------------------------------------------------
NoteInfoStrukt GetXMLNote(string XMLString, int index)
{
 NoteInfoStrukt myNoteInfo;

 int tempIndex=0;
 int count=0;
 string tempString=XMLString;

 myNoteInfo.Node=&quot;&quot;;

 while((tempIndex=tempString.find(&quot;\\&quot;))&gt;=0)
 {
 if(count==0)
 count++;
 count++;
 tempString=tempString.substr(tempIndex+1);
 }

 tempString = XMLString;

 if((index&lt;=count)&amp;&amp;(index&gt;0))
 {
 for(int i=0; i&lt;index;i++)
 {
  if(index&lt;count)
 myNoteInfo.Node=tempString.substr(0,tempString.find(&quot;\\&quot;));
 else
 myNoteInfo.Node=tempString;
 tempString=tempString.substr(tempString.find(&quot;\\&quot;)+1);
 }
 }

 myNoteInfo.count=count; // Gesamtanzahl an Argumente zurückgeben

 return myNoteInfo;
}
</code></pre>
<p>XML.hpp:</p>
<pre><code class="language-cpp">#ifndef XMLH
#define XMLH
//---------------------------------------------------------------------------
//
// XML - Header Datei
//
// Funktionen:
//
//  bool SaveProfileOption(string , string , string ) 
//
//
//---------------------------------------------------------------------------
//
#include &lt;Classes.hpp&gt;
#include &lt;Controls.hpp&gt;
#include &lt;StdCtrls.hpp&gt;
#include &lt;Forms.hpp&gt;
#include &lt;ExtCtrls.hpp&gt;
#include &quot;CSPIN.h&quot;
#include &lt;Graphics.hpp&gt;
#include &lt;oxmldom.hpp&gt;
#include &lt;XMLDoc.hpp&gt;
#include &lt;xmldom.hpp&gt;
#include &lt;XMLIntf.hpp&gt;

#include &lt;string&gt;

//
//---------------------------------------------------------------------------
using namespace std;

struct NoteInfoStrukt {
 int count;
 string Node;
};

bool SaveXMLOption(string FileName, string XMLString, string ChildContent);
NoteInfoStrukt GetXMLNote(string XMLString, int index);

#endif
</code></pre>
<p>Unit123.cpp:</p>
<pre><code class="language-cpp">#include &quot;XML.hpp&quot;

.....

SaveXMLOption(&quot;profile.xml&quot;,&quot;Haupt\\Unterpunkt\\Menu\\Schritt1&quot;, &quot;Test1&quot;);
SaveXMLOption(&quot;profile.xml&quot;,&quot;Haupt\\Unterpunkt\\Menu\\Schritt2&quot;, &quot;Test2&quot;);
SaveXMLOption(&quot;profile.xml&quot;,&quot;Haupt\\Unterpunkt\\Menu\\Schritt3&quot;, &quot;Test3&quot;);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/90449/anwendung-verwirrender-fehler-bei-xml-datei</link><generator>RSS for Node</generator><lastBuildDate>Tue, 07 Jul 2026 01:13:47 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/90449.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 29 Oct 2004 12:23:30 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Anwendung: verwirrender Fehler bei XML - Datei on Fri, 29 Oct 2004 12:23:30 GMT]]></title><description><![CDATA[<p>Hallo!</p>
<p>Zuerst schonmal:<br />
Ja, ich habe die FAQ gelesen, und die Borland Hilfe und TROTZDEM hänge ich seit 2 Tagen über dem Problem:<br />
Ich möchte einige Einstellungen aus meinem Programm in eine XML Datei speichern. Diese wird bei Bedarf, wenn sie noch nicht existiert, erstellt.<br />
Klappt auch alles.<br />
Dann übergebe ich meiner XML-Funktion einen String, z.b.: &quot;Hallo\\das\\ist\\ein\\test&quot;. In der XML Datei soll dann dies stehen:</p>
<pre><code>&lt;Hallo&gt;
   &lt;das&gt;
      &lt;ist&gt;
        ....
           &lt;Eintrag1&gt;1&lt;/Eintrag1&gt;
           &lt;Eintrag2&gt;1&lt;/Eintrag2&gt;
           &lt;Eintrag3&gt;1&lt;/Eintrag3&gt;
        .... 
      &lt;/ist&gt;
   &lt;/das&gt;
&lt;/Hallo&gt;
</code></pre>
<p>Das macht er auch...ABER..<br />
wenn ich nun Werte einfügen will, dann Schreibt er die Einträge hintereinander, nicht untereinander (d.h. er schreibt kein newline in die XML Datei).</p>
<pre><code>&lt;Hallo&gt;
   &lt;das&gt;
      &lt;ist&gt;
        ....
           &lt;Eintrag1&gt;1&lt;/Eintrag1&gt;&lt;Eintrag2&gt;1&lt;/Eintrag2&gt;&lt;Eintrag3&gt;1&lt;/Eintrag3&gt;
        .... 
      &lt;/ist&gt;
   &lt;/das&gt;
&lt;/Hallo&gt;
</code></pre>
<p>Das heißt ja im Prinzip, dass irgendwo im Code ein Fehler ist.<br />
Hier der Copy-Paste Code zum selber Probieren:</p>
<p>Ich würde mich über eine Rückmeldung freuen!</p>
<p>XML.cpp:</p>
<pre><code class="language-cpp">#include &lt;vcl.h&gt;
#include &lt;string&gt;
#pragma hdrstop

#include &quot;XML.hpp&quot;

using namespace std;

//---------------------------------------------------------------------------
// XML - Datei speichern / anlegen
//---------------------------------------------------------------------------
bool SaveXMLOption(string FileName, string XMLString, string ChildContent)
{
int count=GetXMLNote(XMLString,0).count;
_di_IXMLNode tempKnoten1,tempKnoten2;

NoteInfoStrukt tempNoteInfo =GetXMLNote(XMLString,1);

if(XMLString==&quot;&quot;)  // XMLString darf nicht leer sein
return false;

 if(FileExists(FileName.c_str()))
  {
    try
    {
       _di_IXMLDocument XMLDocument = LoadXMLDocument(FileName.c_str());
      XMLDocument-&gt;Active = true;
      tempKnoten1 = XMLDocument-&gt;DocumentElement;
    for(int i=2;i&lt;count;i++)
   {
   if(i%2)
   {
    if(tempKnoten2-&gt;ChildNodes-&gt;FindNode((tempNoteInfo = GetXMLNote(XMLString,i)).Node.c_str())==NULL)
    tempKnoten1 = tempKnoten2-&gt;AddChild(tempNoteInfo.Node.c_str());
    else
    tempKnoten1 =  tempKnoten2-&gt;ChildNodes-&gt;FindNode((tempNoteInfo = GetXMLNote(XMLString,i)).Node.c_str());
      }
   else
    {
    if(tempKnoten1-&gt;ChildNodes-&gt;FindNode((tempNoteInfo = GetXMLNote(XMLString,i)).Node.c_str())==NULL)
    tempKnoten2 = tempKnoten1-&gt;AddChild((tempNoteInfo =GetXMLNote(XMLString,i)).Node.c_str());
    else
      tempKnoten2 =  tempKnoten1-&gt;ChildNodes-&gt;FindNode((tempNoteInfo = GetXMLNote(XMLString,i)).Node.c_str());
      }
   }
   if(count%2)
   if(tempKnoten2-&gt;ChildNodes-&gt;FindNode((tempNoteInfo = GetXMLNote(XMLString,count)).Node.c_str())!=NULL)
    tempKnoten2-&gt;ChildNodes-&gt;Delete((tempNoteInfo = GetXMLNote(XMLString,count)).Node.c_str());
   else
   if(tempKnoten1-&gt;ChildNodes-&gt;FindNode((tempNoteInfo = GetXMLNote(XMLString,count)).Node.c_str())!=NULL)
    tempKnoten1-&gt;ChildNodes-&gt;Delete((tempNoteInfo = GetXMLNote(XMLString,count)).Node.c_str());

   _di_IXMLNode Node = XMLDocument-&gt;CreateElement((tempNoteInfo =GetXMLNote(XMLString,count)).Node.c_str(), L&quot;&quot;);
   Node-&gt;NodeValue = WideString(ChildContent.c_str());
   if(count%2)
    tempKnoten2-&gt;ChildNodes-&gt;Add(Node);
   else
    tempKnoten1-&gt;ChildNodes-&gt;Add(Node);

    // XML Dokument in eine Datei abspeichern
    XMLDocument-&gt;FileName=FileName.c_str();
    XMLDocument-&gt;SaveToFile(XMLDocument-&gt;FileName);
  }
    catch (...){
  return false; }

  return true;
  }
  else
  {
   try
    {

TXMLDocument *XMLDocument = new TXMLDocument(&quot;&quot;); // WICHTIG: kein Datei Namen übergeben, sonst Exception

XMLDocument-&gt;Options = XMLDocument-&gt;Options &lt;&lt; doNodeAutoIndent;  // für die richtige Formatierung
XMLDocument-&gt;Active = true;
XMLDocument-&gt;Encoding = &quot;UTF-16&quot;;    // Encoding festlegen, damit auch z.B. Umlauten richtig rüberkommen
XMLDocument-&gt;FileName=FileName.c_str();

tempKnoten1 = XMLDocument-&gt;CreateElement((tempNoteInfo =GetXMLNote(XMLString,1)).Node.c_str(), &quot;&quot;);
XMLDocument-&gt;DocumentElement = tempKnoten1;

   for(int i=2;i&lt;count;i++)
   {
   if(i%2)
    if(tempKnoten2-&gt;ChildNodes-&gt;FindNode((tempNoteInfo = GetXMLNote(XMLString,i)).Node.c_str())==NULL)
    tempKnoten1 = tempKnoten2-&gt;AddChild(tempNoteInfo.Node.c_str());
    else
      tempKnoten1 =  tempKnoten2-&gt;ChildNodes-&gt;FindNode((tempNoteInfo = GetXMLNote(XMLString,i)).Node.c_str());
   else
    if(tempKnoten1-&gt;ChildNodes-&gt;FindNode((tempNoteInfo = GetXMLNote(XMLString,i)).Node.c_str())==NULL)
    tempKnoten2 = tempKnoten1-&gt;AddChild((tempNoteInfo =GetXMLNote(XMLString,i)).Node.c_str());
    else
      tempKnoten2 =  tempKnoten1-&gt;ChildNodes-&gt;FindNode((tempNoteInfo = GetXMLNote(XMLString,i)).Node.c_str());
   }
   _di_IXMLNode Node = XMLDocument-&gt;CreateElement((tempNoteInfo =GetXMLNote(XMLString,count)).Node.c_str(), L&quot;&quot;);
   Node-&gt;NodeValue = WideString(ChildContent.c_str());
   if(count%2)
    tempKnoten2-&gt;ChildNodes-&gt;Add(Node);
    else
    tempKnoten1-&gt;ChildNodes-&gt;Add(Node);

    // XML Dokument in eine Datei abspeichern
    XMLDocument-&gt;SaveToFile();
  }
  catch (...)
  {
   return false;
  }

  return true;
  }
}
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
// XML - Knoten rausfiltern
//---------------------------------------------------------------------------
NoteInfoStrukt GetXMLNote(string XMLString, int index)
{
 NoteInfoStrukt myNoteInfo;

 int tempIndex=0;
 int count=0;
 string tempString=XMLString;

 myNoteInfo.Node=&quot;&quot;;

 while((tempIndex=tempString.find(&quot;\\&quot;))&gt;=0)
 {
 if(count==0)
 count++;
 count++;
 tempString=tempString.substr(tempIndex+1);
 }

 tempString = XMLString;

 if((index&lt;=count)&amp;&amp;(index&gt;0))
 {
 for(int i=0; i&lt;index;i++)
 {
  if(index&lt;count)
 myNoteInfo.Node=tempString.substr(0,tempString.find(&quot;\\&quot;));
 else
 myNoteInfo.Node=tempString;
 tempString=tempString.substr(tempString.find(&quot;\\&quot;)+1);
 }
 }

 myNoteInfo.count=count; // Gesamtanzahl an Argumente zurückgeben

 return myNoteInfo;
}
</code></pre>
<p>XML.hpp:</p>
<pre><code class="language-cpp">#ifndef XMLH
#define XMLH
//---------------------------------------------------------------------------
//
// XML - Header Datei
//
// Funktionen:
//
//  bool SaveProfileOption(string , string , string ) 
//
//
//---------------------------------------------------------------------------
//
#include &lt;Classes.hpp&gt;
#include &lt;Controls.hpp&gt;
#include &lt;StdCtrls.hpp&gt;
#include &lt;Forms.hpp&gt;
#include &lt;ExtCtrls.hpp&gt;
#include &quot;CSPIN.h&quot;
#include &lt;Graphics.hpp&gt;
#include &lt;oxmldom.hpp&gt;
#include &lt;XMLDoc.hpp&gt;
#include &lt;xmldom.hpp&gt;
#include &lt;XMLIntf.hpp&gt;

#include &lt;string&gt;

//
//---------------------------------------------------------------------------
using namespace std;

struct NoteInfoStrukt {
 int count;
 string Node;
};

bool SaveXMLOption(string FileName, string XMLString, string ChildContent);
NoteInfoStrukt GetXMLNote(string XMLString, int index);

#endif
</code></pre>
<p>Unit123.cpp:</p>
<pre><code class="language-cpp">#include &quot;XML.hpp&quot;

.....

SaveXMLOption(&quot;profile.xml&quot;,&quot;Haupt\\Unterpunkt\\Menu\\Schritt1&quot;, &quot;Test1&quot;);
SaveXMLOption(&quot;profile.xml&quot;,&quot;Haupt\\Unterpunkt\\Menu\\Schritt2&quot;, &quot;Test2&quot;);
SaveXMLOption(&quot;profile.xml&quot;,&quot;Haupt\\Unterpunkt\\Menu\\Schritt3&quot;, &quot;Test3&quot;);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/640293</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/640293</guid><dc:creator><![CDATA[Genscher]]></dc:creator><pubDate>Fri, 29 Oct 2004 12:23:30 GMT</pubDate></item><item><title><![CDATA[Reply to Anwendung: verwirrender Fehler bei XML - Datei on Fri, 29 Oct 2004 17:34:22 GMT]]></title><description><![CDATA[<p>Was mir jetzt spontan auffällt, ist, dass die Zeile</p>
<pre><code class="language-cpp">XMLDocument-&gt;Options = XMLDocument-&gt;Options &lt;&lt; doNodeAutoIndent;  // für die richtige Formatierung
</code></pre>
<p>nur dann ausgeführt wird, wenn die Datei neu angelegt wird.<br />
Vielleicht solltest Du Dir auch mal überlegen, den Code etwas übersichtlicher zu gestalten und zu kommentieren.<br />
Von der Vorgehensweise her würde ich erstmal dafür sorgen eine gültige XMLDocument-Instanz zu haben, d.h. entweder eine bestehende Datei laden oder<br />
eine neue Instanz erstellen.<br />
Dann würde ich alles darauf loslassen, anstatt per Copy'n'Paste den Code doppelt reinzuklatschen. Diese &quot;Programmiermethode&quot; sorgt meines Erachtens<br />
für schlecht lesbaren und vor allem schlecht wartbaren Code (alle Änderungen müssen doppelt eingepflegt werden). Wenn meine obige Vermutung stimmt,<br />
wäre das schon der Beweis <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
<p>Gruß,</p>
<p>Alexander</p>
]]></description><link>https://www.c-plusplus.net/forum/post/640585</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/640585</guid><dc:creator><![CDATA[Alexander Kempf]]></dc:creator><pubDate>Fri, 29 Oct 2004 17:34:22 GMT</pubDate></item><item><title><![CDATA[Reply to Anwendung: verwirrender Fehler bei XML - Datei on Sun, 31 Oct 2004 10:07:18 GMT]]></title><description><![CDATA[<p>....shame on me <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /></p>
<p>Hallo!</p>
<p>Danke für die Antwort und natürlich hast du recht.</p>
<p>Es lag an der einen Zeile, die du zitiert hattest.<br />
Und natürlich mache ich mich mal ans Aufräumen des Codes.</p>
<p>Einen schönen Tag noch!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/641470</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/641470</guid><dc:creator><![CDATA[Genscher]]></dc:creator><pubDate>Sun, 31 Oct 2004 10:07:18 GMT</pubDate></item><item><title><![CDATA[Reply to Anwendung: verwirrender Fehler bei XML - Datei on Sun, 31 Oct 2004 11:36:51 GMT]]></title><description><![CDATA[<p>So, die Zusammenlegung ist soweit abgeschlossen.</p>
<p>Jedoch bekomme ich jetzt immer eine Exception bei der Ausführung, wenn die XML-Datei schon vorhanden ist:</p>
<pre><code class="language-cpp">_di_IXMLNode tempKnoten1,tempKnoten2;

TXMLDocument *XMLDocument=new TXMLDocument(&quot;&quot;); // WICHTIG: kein Datei Namen übergeben, sonst Exception

  XMLDocument-&gt;FileName=FileName.c_str();
  XMLDocument-&gt;Options = XMLDocument-&gt;Options &lt;&lt; doNodeAutoIndent;  // für die richtige Formatierung
  XMLDocument-&gt;LoadFromFile();
  XMLDocument-&gt;Active = true;
  if(XMLDocument-&gt;IsEmptyDoc()) // Gibt es die XML - Datei schon? 
  { // nein, dann neu erstellen
  XMLDocument-&gt;Encoding = &quot;UTF-16&quot;;    // Encoding festlegen, damit auch z.B. Umlauten richtig rüberkommen
  tempKnoten1 = XMLDocument-&gt;CreateElement((tempNoteInfo =GetXMLNote(XMLString,1)).Node.c_str(), &quot;&quot;);
  XMLDocument-&gt;DocumentElement = tempKnoten1;
  }
  else // Ja, dann den root - Knoten erhalten 
  tempKnoten1 = XMLDocument-&gt;DocumentElement; // &lt;-- Hier die Exception
</code></pre>
<p>Er kann irgendwie nicht den root-Knoten &quot;XMLDocument-&gt;DocumentElement&quot; erhalten.<br />
Jedoch ist die XML - Datei fehlerfrei, denn Aktive ist auch auf &quot;true&quot; und &quot;IsEmptyDoc&quot; auch false.</p>
<p>Weiß jemand weiter?</p>
<p>Hier zum nachvollziehen der Inhalt der XML-Datei</p>
<pre><code class="language-cpp">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-16&quot;?&gt;
&lt;PROFILES&gt;
  &lt;TEST&gt;
    &lt;Wizzard&gt;
      &lt;Step1&gt;Test1&lt;/Step1&gt;
    &lt;/Wizzard&gt;
  &lt;/TEST&gt;
&lt;/PROFILES&gt;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/641546</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/641546</guid><dc:creator><![CDATA[Genscher]]></dc:creator><pubDate>Sun, 31 Oct 2004 11:36:51 GMT</pubDate></item></channel></rss>