Als Ergebnis wurde zwei Bibliotheken gefunden und beide erfordern einige Korrekturen.
1."Haxe XPath"
kann es nur Verzeichnis "haxe-XPath/src/xpath" in Sie Quellen, wenn Klon verwendet werden (haxelib Repo ist diese Bibliothek nicht enthält).
wurde Einige der Updates für diese Bibliothek benötigt: this und this
Beispiel (löschen erstes Element gefunden):
package;
import xpath.XPathHx;
using Lambda;
class Main {
public static function main() {
var xml = Xml.parse("<a> <b> <c>qwe</c> <c>asd</c> </b> </a>");
trace(xml.toString());
var xpExpr = new XPathHx("//a/b/c"); // create new XPath expression object
var result = xpExpr.selectNodes(xml).array()[0]; // get first element from array of founded xml-nodes
result.parent.removeChild(result); // remove selected node from xml-tree
trace(xml.toString());
}
}
2."xmlTools"
es kann mit Haxelib installiert werden:
haxelib install xmlTools
haxelib install composure
Some fix was needed for this library (in my task) und ein nuance for xpath.
Beispiel (löschen zuerst gefunden Element):
package;
import xmlTools.XPath;
using Lambda;
class Main {
public static function main() {
var xml = Xml.parse("<a> <b> <c>qwe</c> <c>asd</c> </b> </a>");
trace(xml.toString());
var xpath = new XPath(); // create new XPath expression object
var result = xpath.resolve(xml, "*/a/b/c").array()[0]; // get first element from array of founded xml-nodes
result.parent.removeChild(result); // remove selected node from xml-tree
trace(xml.toString());
}
}
für Bibliothek "haxe-xpath" wurde einige kleine Korrekturen gemacht https://github.com/djcsdy/haxe-xpath/issues/26 –