我正在尝试使用Altova XMLSpy中的in-build XQuery编译器通过XQuery删除XML节点。
xquery version "1.0" encoding "UTF-8";
for $customer in doc("Customers.xml")/dataroot/Customers
where $customer/CustomerID = "ALFKI"
return delete node $customer;
问题是编译器没有将“删除节点”视为有效语法,而是在此处定义:http://www.w3.org/TR/xquery-update-10/
它抱怨错误“意外的令牌节点$ customer”。
有什么想法吗?
答案 0 :(得分:2)
事实是XMLSpy不支持XQuery Update Facility,因此delete关键字无效
答案 1 :(得分:1)
在$customer
之后删除错失的分号。
xquery version "1.0" encoding "UTF-8";
for $customer in doc("Customers.xml")/dataroot/Customers
where $customer/CustomerID = "ALFKI"
return delete node $customer (: here was the semicolon :)
否则,您的XQuery有效。