stop html encode select ... for xml path

select '<p> hi there <b>joe!</b></p>' as 'welcome'
for xml path('greetings')

returns: <greetings><welcome>&lt;p&gt; hi there &lt;b&gt;joe!&lt;/b&gt;&lt;/p&gt;</welcome></greetings>

I want: <greetings><welcome><p> hi there <b>joe!</b></p></welcome></greetings>

Are there any options?
LVL 3
leos_Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Anthony PerkinsCommented:
select      '' welcome,
            ' hi there ' [welcome/p],
            'joe!' [welcome/p/b]
for xml path('greetings')
leos_Author Commented:
hehe acperkins ...  not quite what I'm after, unless you're telling me it can't be done.

Here is a clarification.

select HTMLColumn as Welcome
from SomeTable
for xml path('greeting')

the entries in HTMLColumn are:

1.  <p>hi there <b>joe!</b></p>
2.  <p>Dear bob,</p>
3.  <p>You Rock! <i>we want you back</i>.  Call us</p>
4.  ??? who knows

upped point value to 500
leos_Author Commented:
oh, and give the above table, I don't want the results htmlencoded.
IT Pros Agree: AI and Machine Learning Key

We’d all like to think our company’s data is well protected, but when you ask IT professionals they admit the data probably is not as safe as it could be.

Anthony PerkinsCommented:
The best you can achieve with that approach is:

select HTMLColumn [welcome/comment()]
from SomeTable
for xml path('greeting')

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
leos_Author Commented:
Thanks Anthony,

I think I can find a way to remove the comment markers after the fact.

Is the comment() function documented somewhere?

Jens
Anthony PerkinsCommented:
>>Is the comment() function documented somewhere? <<
It is under "Using PATH Mode" in BOL in the "Columns with the name of an XPath Node Test" section
http://msdn.microsoft.com/en-us/library/ms189885(SQL.90).aspx
 
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2005

From novice to tech pro — start learning today.