<?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[[tinyxpath] XNp_get_xpath_node liefert falsche nodes?]]></title><description><![CDATA[<p>aaalso ich habe eine Datei, die sieht so aus:</p>
<pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;game&gt;
  &lt;switch end=&quot;good&quot; id=&quot;1&quot;&gt;
    &lt;modify type=&quot;attribute&quot;&gt;
      &lt;path&gt;//object/@name&lt;/path&gt;
      &lt;objectid&gt;1&lt;/objectid&gt;
      &lt;modified&gt;Kurt&lt;/modified&gt;
    &lt;/modify&gt;
  &lt;/switch&gt;
  &lt;switch end=&quot;bad&quot; id=&quot;2&quot;&gt;
  	&lt;modify type=&quot;attribute&quot;&gt;
  		&lt;path&gt;//object/@active&lt;/path&gt;
  		&lt;objectid&gt;1&lt;/objectid&gt;
  		&lt;modified&gt;false&lt;/modified&gt;
  	&lt;/modify&gt;
  &lt;/switch&gt;
  &lt;object active=&quot;true&quot; id=&quot;1&quot; name=&quot;Hans&quot;/&gt;
  &lt;action name=&quot;kill&quot;&gt;
  	&lt;who&gt;0&lt;/who&gt;
  	&lt;whom&gt;1&lt;/whom&gt;
  	&lt;switches&gt;2&lt;/switches&gt;
  &lt;/action&gt;
  &lt;action name=&quot;rename&quot;&gt;
    &lt;who&gt;0&lt;/who&gt;
    &lt;whom&gt;1&lt;/whom&gt;
    &lt;switches&gt;1&lt;/switches&gt;
  &lt;/action&gt;
&lt;/game&gt;
</code></pre>
<p>ich hab mir für den Zugriff tinyxpath kompiliert<br />
folgdenen Zugriff mache ich:</p>
<p>/game/action[@name='kill']</p>
<p>Das Ganze mit diesem Code:</p>
<pre><code class="language-cpp">// finde alle Aktionen mit dem Namen action@name
		string actionName = TinyXPath::S_xpath_string(action, ACTION_NAME).c_str();
		actionName = REQUEST_ACTION_BY_NAME(actionName);

		TinyXPath::xpath_processor prc(doc.FirstChild(), actionName.c_str());
		unsigned ui = prc.u_compute_xpath_node_set();

		#ifdef _TEST_
				cout &lt;&lt; &quot;requesting &quot; &lt;&lt; actionName.c_str() &lt;&lt; endl;
				cout &lt;&lt; ui &lt;&lt; &quot; items found &quot; &lt;&lt; endl;
		#endif

		// hole füge sämtliche Objekte dem ObjectPool hinzu
		for (unsigned i = 0; i &lt; ui; i ++) {
			TiXmlNode *item = prc.XNp_get_xpath_node(i);

			#ifdef _TEST_
					cout &lt;&lt; TinyXPath::S_xpath_string(item, &quot;/action/@name&quot;).c_str() &lt;&lt; endl;
			#endif
		}
</code></pre>
<p>Was ich jetzt aber zurück bekomme ist leider kein Element mit dem actionname 'kill' sondern 'rename'<br />
Auch bei anderen Requests ist das so. Immer, wenn ich über die Konstellation<br />
prc.u_compute_xpath_node_set() / prc.XNp_get_xpath_node(i) arbeite, kommt nicht das richtige, sondern sinnfreierweise das letzte item in der liste heraus, welches dem xpath ohne Attributprüfung entspricht..</p>
<p>kann mir wer sagen, was hier kaputt ist?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/216548/tinyxpath-xnp_get_xpath_node-liefert-falsche-nodes</link><generator>RSS for Node</generator><lastBuildDate>Sun, 11 Oct 2026 09:51:54 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/216548.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 25 Jun 2008 11:20:15 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [tinyxpath] XNp_get_xpath_node liefert falsche nodes? on Wed, 25 Jun 2008 11:20:15 GMT]]></title><description><![CDATA[<p>aaalso ich habe eine Datei, die sieht so aus:</p>
<pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;game&gt;
  &lt;switch end=&quot;good&quot; id=&quot;1&quot;&gt;
    &lt;modify type=&quot;attribute&quot;&gt;
      &lt;path&gt;//object/@name&lt;/path&gt;
      &lt;objectid&gt;1&lt;/objectid&gt;
      &lt;modified&gt;Kurt&lt;/modified&gt;
    &lt;/modify&gt;
  &lt;/switch&gt;
  &lt;switch end=&quot;bad&quot; id=&quot;2&quot;&gt;
  	&lt;modify type=&quot;attribute&quot;&gt;
  		&lt;path&gt;//object/@active&lt;/path&gt;
  		&lt;objectid&gt;1&lt;/objectid&gt;
  		&lt;modified&gt;false&lt;/modified&gt;
  	&lt;/modify&gt;
  &lt;/switch&gt;
  &lt;object active=&quot;true&quot; id=&quot;1&quot; name=&quot;Hans&quot;/&gt;
  &lt;action name=&quot;kill&quot;&gt;
  	&lt;who&gt;0&lt;/who&gt;
  	&lt;whom&gt;1&lt;/whom&gt;
  	&lt;switches&gt;2&lt;/switches&gt;
  &lt;/action&gt;
  &lt;action name=&quot;rename&quot;&gt;
    &lt;who&gt;0&lt;/who&gt;
    &lt;whom&gt;1&lt;/whom&gt;
    &lt;switches&gt;1&lt;/switches&gt;
  &lt;/action&gt;
&lt;/game&gt;
</code></pre>
<p>ich hab mir für den Zugriff tinyxpath kompiliert<br />
folgdenen Zugriff mache ich:</p>
<p>/game/action[@name='kill']</p>
<p>Das Ganze mit diesem Code:</p>
<pre><code class="language-cpp">// finde alle Aktionen mit dem Namen action@name
		string actionName = TinyXPath::S_xpath_string(action, ACTION_NAME).c_str();
		actionName = REQUEST_ACTION_BY_NAME(actionName);

		TinyXPath::xpath_processor prc(doc.FirstChild(), actionName.c_str());
		unsigned ui = prc.u_compute_xpath_node_set();

		#ifdef _TEST_
				cout &lt;&lt; &quot;requesting &quot; &lt;&lt; actionName.c_str() &lt;&lt; endl;
				cout &lt;&lt; ui &lt;&lt; &quot; items found &quot; &lt;&lt; endl;
		#endif

		// hole füge sämtliche Objekte dem ObjectPool hinzu
		for (unsigned i = 0; i &lt; ui; i ++) {
			TiXmlNode *item = prc.XNp_get_xpath_node(i);

			#ifdef _TEST_
					cout &lt;&lt; TinyXPath::S_xpath_string(item, &quot;/action/@name&quot;).c_str() &lt;&lt; endl;
			#endif
		}
</code></pre>
<p>Was ich jetzt aber zurück bekomme ist leider kein Element mit dem actionname 'kill' sondern 'rename'<br />
Auch bei anderen Requests ist das so. Immer, wenn ich über die Konstellation<br />
prc.u_compute_xpath_node_set() / prc.XNp_get_xpath_node(i) arbeite, kommt nicht das richtige, sondern sinnfreierweise das letzte item in der liste heraus, welches dem xpath ohne Attributprüfung entspricht..</p>
<p>kann mir wer sagen, was hier kaputt ist?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1535468</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1535468</guid><dc:creator><![CDATA[DocJunioR]]></dc:creator><pubDate>Wed, 25 Jun 2008 11:20:15 GMT</pubDate></item></channel></rss>