Solved

SQL XML Parse

Posted on 2015-02-05
1
98 Views
Last Modified: 2015-02-08
How to query to get value of xml element when shown as below.
 
I have this in an xml doc . I can query and get any value successfully however  this returns a null every-time, does this require special handling while querying XML.


I have tried OpenXml and node() function everything returns NULL...
doc.col.value('ListPrice[1]', 'float') Price   --RETURNS NULL

 
<ListPrice Type="FLOAT" CurrencyCode="USD">139900.00</ListPrice>

Open in new window

0
Comment
Question by:leadcodev
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 12

Accepted Solution

by:
Habib Pourfard earned 500 total points
ID: 40592905
it works for me:
DECLARE @XMLData XML = '<ListPrice Type="FLOAT" CurrencyCode="USD">139900.00</ListPrice>'
SELECT @XMLData.value('ListPrice[1]','float')

Open in new window

0

Featured Post

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have written a PowerShell script to "walk" the security structure of each SQL instance to find:         Each Login (Windows or SQL)             * Its Server Roles             * Every database to which the login is mapped             * The associated "Database User" for this …
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question