D
aaalso ich habe eine Datei, die sieht so aus:
<?xml version="1.0" encoding="UTF-8"?>
<game>
<switch end="good" id="1">
<modify type="attribute">
<path>//object/@name</path>
<objectid>1</objectid>
<modified>Kurt</modified>
</modify>
</switch>
<switch end="bad" id="2">
<modify type="attribute">
<path>//object/@active</path>
<objectid>1</objectid>
<modified>false</modified>
</modify>
</switch>
<object active="true" id="1" name="Hans"/>
<action name="kill">
<who>0</who>
<whom>1</whom>
<switches>2</switches>
</action>
<action name="rename">
<who>0</who>
<whom>1</whom>
<switches>1</switches>
</action>
</game>
ich hab mir für den Zugriff tinyxpath kompiliert
folgdenen Zugriff mache ich:
/game/action[@name='kill']
Das Ganze mit diesem Code:
// 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 << "requesting " << actionName.c_str() << endl;
cout << ui << " items found " << endl;
#endif
// hole füge sämtliche Objekte dem ObjectPool hinzu
for (unsigned i = 0; i < ui; i ++) {
TiXmlNode *item = prc.XNp_get_xpath_node(i);
#ifdef _TEST_
cout << TinyXPath::S_xpath_string(item, "/action/@name").c_str() << endl;
#endif
}
Was ich jetzt aber zurück bekomme ist leider kein Element mit dem actionname 'kill' sondern 'rename'
Auch bei anderen Requests ist das so. Immer, wenn ich über die Konstellation
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..
kann mir wer sagen, was hier kaputt ist?