1

I'd like to insert some test xml data into a table before executing a stored proc that parses the xml and populates another table.

Setup: Insert test data
|execute|!- 
 Insert into dbo.XML_Table
  Values
  (
  '<Document File="123" NoOfPages="1">
  <Page Number="1">
  </Page>
</Document>',
  GetDate()
  )
-!|

The query works fine in SQL Server management studio

Insert into dbo.XML_Table
      Values
      (
      '<Document File="123" NoOfPages="1">
      <Page Number="1">
      </Page>
    </Document>',
      GetDate()
      )

However, when I save the test in dbfit, it looks like this in the browser

Setup: Insert test data
execute
Insert into dbo.XML_Table Values ( 99, ' ', GetDate(), 'gilbert' )

When I run the test, it appears to execute ok. There are no errors. I ran SQL Server profiler and can't see the query there.

I have 30+ other tests in this project that run ok, all selecting data.

Can anyone help?

benilov
  • 1,234
  • 11
  • 11
Gilbert Liddell
  • 1,203
  • 4
  • 14
  • 21

1 Answers1

0

Looks like the XML markup is getting confused with HTML markup. Try escaping the XML:

'&lt;Document File="123" NoOfPages="1"&gt;

etc

Mike Stockdale
  • 5,256
  • 3
  • 29
  • 33
  • Can't believe i didn't think of that. Still not inserting the row into the database but that's another issue so i'll mark this as answered. – Gilbert Liddell Aug 04 '11 at 07:50