<?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[TinyXML Attributwerte ändern]]></title><description><![CDATA[<p>Hi,</p>
<p>ich habe eine xml Datei der Form:</p>
<p>&lt;root&gt;<br />
&lt;Icon name=&quot;1a&quot; X=&quot;2.5&quot; Y=&quot;2.6&quot; Z=&quot;4.0&quot; /&gt;<br />
...<br />
&lt;/root&gt;</p>
<p>Die Werte schreibe ich per:</p>
<pre><code>TiXmlElement* root;
	TiXmlElement wert(&quot;Icon&quot;);

	// Set attributes for an Element. 
	// The arguments must be converted from string to (char*)
	wert.SetAttribute(&quot;Name&quot;, name);
	wert.SetAttribute(&quot;X&quot;, (char*)xString.c_str());
	wert.SetAttribute(&quot;Y&quot;, (char*)yString.c_str());
	wert.SetAttribute(&quot;Z&quot;, (char*)zString.c_str());

	// Get the root Element and insert Icon as child
	root = doc.FirstChildElement(&quot;root&quot;);
	if (root)
		root-&gt;InsertEndChild(wert);
</code></pre>
<p>Dabei werden beim Schreiben aber die Elemente immer neu hinzugefügt. Wie kann man nur die Attribute eines Elementes ändern, wenn es schon vorhanden ist?</p>
<p>Gruß<br />
Alex</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/226453/tinyxml-attributwerte-ändern</link><generator>RSS for Node</generator><lastBuildDate>Wed, 30 Sep 2026 23:24:48 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/226453.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 01 Nov 2008 13:22:23 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to TinyXML Attributwerte ändern on Sat, 01 Nov 2008 13:22:23 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>ich habe eine xml Datei der Form:</p>
<p>&lt;root&gt;<br />
&lt;Icon name=&quot;1a&quot; X=&quot;2.5&quot; Y=&quot;2.6&quot; Z=&quot;4.0&quot; /&gt;<br />
...<br />
&lt;/root&gt;</p>
<p>Die Werte schreibe ich per:</p>
<pre><code>TiXmlElement* root;
	TiXmlElement wert(&quot;Icon&quot;);

	// Set attributes for an Element. 
	// The arguments must be converted from string to (char*)
	wert.SetAttribute(&quot;Name&quot;, name);
	wert.SetAttribute(&quot;X&quot;, (char*)xString.c_str());
	wert.SetAttribute(&quot;Y&quot;, (char*)yString.c_str());
	wert.SetAttribute(&quot;Z&quot;, (char*)zString.c_str());

	// Get the root Element and insert Icon as child
	root = doc.FirstChildElement(&quot;root&quot;);
	if (root)
		root-&gt;InsertEndChild(wert);
</code></pre>
<p>Dabei werden beim Schreiben aber die Elemente immer neu hinzugefügt. Wie kann man nur die Attribute eines Elementes ändern, wenn es schon vorhanden ist?</p>
<p>Gruß<br />
Alex</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1608526</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1608526</guid><dc:creator><![CDATA[filth]]></dc:creator><pubDate>Sat, 01 Nov 2008 13:22:23 GMT</pubDate></item><item><title><![CDATA[Reply to TinyXML Attributwerte ändern on Sat, 01 Nov 2008 13:35:21 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">wert.SetAttribute(&quot;X&quot;, (char*)xString.c_str());
</code></pre>
<p>Pfui! Aus! Böser Neuling! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /><br />
TinyXML unterstütz dies:</p>
<pre><code class="language-cpp">wert.SetAttribute(&quot;X&quot;, xString.c_str());
</code></pre>
<p>Und wenn du mit der Standardbibliothek kompilierst, dann unterstützt TinyXML sogar dies:</p>
<pre><code class="language-cpp">wert.SetAttribute(&quot;X&quot;, xString);
</code></pre>
<p>Zu deinem Problem:<br />
Vielleicht solltest du nicht jedesmal eine neue Node erstellen, sondern die alte holen und verändern?</p>
<pre><code class="language-cpp">TiXmlElement* root = doc.FirstChildElement(&quot;root&quot;);
TiXmlElement* icon = root.FirstChildElement(&quot;Icon&quot;);

// bearbeite icon ...
</code></pre>
<p>Und du könntest dann natürlich über alle Icons iterieren, wie man das macht, kannst du in der Dokumentation von TinyXML nachlesen.</p>
<p>Grüssli</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1608536</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1608536</guid><dc:creator><![CDATA[Dravere]]></dc:creator><pubDate>Sat, 01 Nov 2008 13:35:21 GMT</pubDate></item><item><title><![CDATA[Reply to TinyXML Attributwerte ändern on Sat, 01 Nov 2008 13:44:09 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>ich glaube du irrst dich. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
<p>wert.SetAttribute(&quot;X&quot;, xString.c_str());</p>
<p>wirft bei mir nen Fehler.</p>
<p>Grüße<br />
Alex</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1608542</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1608542</guid><dc:creator><![CDATA[filth]]></dc:creator><pubDate>Sat, 01 Nov 2008 13:44:09 GMT</pubDate></item><item><title><![CDATA[Reply to TinyXML Attributwerte ändern on Sat, 01 Nov 2008 13:56:00 GMT]]></title><description><![CDATA[<p>filth schrieb:</p>
<blockquote>
<p>ich glaube du irrst dich. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
</blockquote>
<p>Definitiv nicht, bei mir geht es und wenn du in der Dokumentation nachsiehst, dann siehst du, dass dies auch unterstützt wird:<br />
<a href="http://www.grinninglizard.com/tinyxmldocs/classTiXmlElement.html" rel="nofollow">http://www.grinninglizard.com/tinyxmldocs/classTiXmlElement.html</a></p>
<p>Deine Konvertierung ist im übrigen sehr gefährlich und hässlich. Nicht nur ist es ein C-Cast, welche man dringend vermeiden sollte, sondern du castest auch ein <code>const</code> weg, was im allgemeinen auch nur zu Fehlern führt! In 99.999999...% der Fälle muss man ein <code>const</code> nicht loswerden. Ich habe es noch NIE erlebt!</p>
<p>filth schrieb:</p>
<blockquote>
<p>wert.SetAttribute(&quot;X&quot;, xString.c_str());<br />
wirft bei mir nen Fehler.</p>
</blockquote>
<p>Äusserst schleche Fehlerbeschreibung!</p>
<p>Grüssli</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1608546</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1608546</guid><dc:creator><![CDATA[Dravere]]></dc:creator><pubDate>Sat, 01 Nov 2008 13:56:00 GMT</pubDate></item><item><title><![CDATA[Reply to TinyXML Attributwerte ändern on Sat, 01 Nov 2008 14:08:51 GMT]]></title><description><![CDATA[<p>Stimmt, ich habe mich getäuscht.</p>
<p>Mit</p>
<pre><code>wert.SetAttribute(&quot;X&quot;, xString.c_str());
</code></pre>
<p>funktioniert es wohl...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1608549</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1608549</guid><dc:creator><![CDATA[filth]]></dc:creator><pubDate>Sat, 01 Nov 2008 14:08:51 GMT</pubDate></item></channel></rss>