因爲結果發現兩個庫,都需要一些修復。
"Haxe XPath"
它只能如果使用克隆目錄 「haXe的-的XPath/src目錄/ XPath的」 到你的來源(haxelib回購不包含此庫)。需要
一些修補此庫:this和this
例如(刪除第一發現元素):
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"
它可以用haxelib安裝:
haxelib install xmlTools
haxelib install composure
Some fix was needed for this library (in my task)和一個nuance for xpath。
例如(刪除第一發現元素):
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());
}
}
用於文庫 「haXe的-的xpath」 被做一些小的修正https://github.com/djcsdy/haxe-xpath/issues/26 –