I am generating XML from SQL Server 2005 using a SELECT
statement with XQuery syntax.
Is there a way to generate end tags for empty elements? Basically the xml output generated from this sql statement feeds into a "legacy" c# xml parser that doesn't like minimized tag elements! Otherwise everything works fine.
select
-- (this generates empty xml element which throws out the parser)
main.sub.query('schoolname').value('.','varchar(50)') "newparent/newchild/newschoolname"
from
@xml.nodes('/parent/child') AS main(sub)
for xml path(''), type)
Thanks
Use an XSLT processor to transform the empty tags to paired tags, or remove them as in the following questions:
XSLT stylesheet replaces self-closing tags with empty paired tags
Removing empty tags from XML via XSLT