1

This XML format is a given (it comes from an app my company runs):

<User display="User">NAME1</User>

So I've been running the following code to try and tease out the true value (NAME1) from this format:

declare @xml xml = '<User display="User">NAME1</User>'
select @xml.value('(User/@display)[1]', 'nvarchar(max)') as USER_NM

I'm using SQL Server 2012. But nothing I try can pick out the NAME1, rather than User. Any ideas?

1 Answer 1

1

Just use this snippet instead:

SELECT @xml.value('(User)[1]', 'nvarchar(max)') as USER_NM

This will read out the textual value of the <User> element - NAME1 in your case

Sign up to request clarification or add additional context in comments.

Comments

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.