replace node in basex xml using xquery -
i trying replace node in xml using following code
string xquery_replace="xquery replace node cidem/shopfloor/foo[/cidem/shopfloor/shopfloorid=1] "+new_gbxml; session.execute(xquery_replace);
so want example change foo node of first shopfloor node
the xml has following content
<cidem> <shopfloor> <shopfloorid>1</shopfloorid> <foo bar="2"> <baz>there</baz> </foo> </shopfloor> <shopfloor> <shopfloorid>2</shopfloorid> <foo bar="5"> <baz>there</baz> </foo> </shopfloor> </cidem>
and receiving following error "[xuty0008] single element, text, attribute, comment or pi expected replace target."
any idea why?
the error message telling whats wrong.
"[xuty0008] single element, text, attribute, comment or pi expected replace target."
means expecting element or text or attribute... target replaced. path in query taking nowhere. read comment proper path.
for ex: if want replace value of attribute bar
shopfloorid
value 1
, path should cidem/shopfloor[shopflorrid="1"]/foo/@bar
Comments
Post a Comment