//
You're reading...
Tips/Tricks

This document already has a ‘DocumentElement’ node

This happens when we do not assign name to each row as well as root element. So by default system takes DocumentElement as node name which at later stage throws error on validating node.Here is a snap shot:

DocumentElement already contains

To resolve this issue, we must have to assign name to the ROOT element. for example this would work:

SELECT * from DoctorsTable FOR XML path, Root('Doctors')

and this one would work also:

SELECT * from DoctorsTable FOR XML path ('Doctor'), Root('Doctors')

and this one as well:

SELECT * from DoctorsTable FOR XML path, AUTO
Advertisements

About Shahan Ayyub

Shahan is a Microsoft Certified Professional of .Net. Mostly self taught programmer and a quick learner, who just love to code and always eager to find unique solutions to the common problems. Currently working as an iOS developer.

Discussion

One thought on “This document already has a ‘DocumentElement’ node

  1. THANKS, SHOW!

    Posted by ANDERSON | August 3, 2015, 8:38 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: