I'm attempting to delete an XML node through XQuery using the in-build XQuery compiler in Altova XMLSpy.
xquery version "1.0" encoding "UTF-8";
for $customer in doc("Customers.xml")/dataroot/Customers
where $customer/CustomerID = "ALFKI"
return delete node $customer;
The issue is the compiler doesn't see 'delete node' as valid syntax, whereas it's defined here: http://www.w3.org/TR/xquery-update-10/
It complains with an error "Unexpected token node $customer".
Any ideas?
Remove the missplaced semicolon after $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 :)
Otherwise, your XQuery is valid.