0

I have a sample XML file and want to use Xquery to insert data into the nodes

<Employees>
<ID>1</ID>
<Company>Northwind Traders</Company>
<Last_x0020_Name>Freehafer</Last_x0020_Name>
<First_x0020_Name>Nancy</First_x0020_Name>
<E-mail_x0020_Address>[email protected]</E-mail_x0020_Address>
<Job_x0020_Title>Sales Representative</Job_x0020_Title>
<Business_x0020_Phone>(123)555-0100</Business_x0020_Phone>
<Home_x0020_Phone>(123)555-0102</Home_x0020_Phone>
<Fax_x0020_Number>(123)555-0103</Fax_x0020_Number>
<Address>123 1st Avenue</Address>
<City>Seattle</City>
<State_x002F_Province>WA</State_x002F_Province>
<ZIP_x002F_Postal_x0020_Code>99999</ZIP_x002F_Postal_x0020_Code>
<Country_x002F_Region>USA</Country_x002F_Region>
<Web_x0020_Page>#http://northwindtraders.com#</Web_x0020_Page>
</Employees>

How would I be able to insert more XML below the current file for example:

<Employees>
<ID>2</ID>
<Company>Another Company</Company>
</Employees

I have tried the following but can't figure it out.

insert nodes <ID>2</ID> after 
doc("Employees.xml")//Employees
4
  • When you say you tried that insert nodes... did you get an error? If so, what did it say? Also, which XQuery processor (and do you know for sure that it supports XQuery Update syntax)? Commented Mar 15, 2013 at 16:51
  • I am using Saxon and I got an error message saying it didn't understand what insert nodes was. I Don't think it supports this function. Commented Mar 17, 2013 at 22:25
  • There are a number of editions of Saxon. As stated on saxon.sourceforge.net, only Saxon EE supports XQuery Update. Commented Mar 18, 2013 at 4:17
  • possible duplicate of Insert multiple nodes to xml field in single query Commented Jun 24, 2014 at 17:06

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.