Extracting values from XML field with unusual XML using SQL -


hoping can -

the xml format put simple syntax, reason i'm struggling parse using standard 'value' type query. i'm experienced sql, have limited experience in xml, , after 2 hours of frustration , googling, thought i'd ask own sanity!

the data stored text string, converting xml before parsing:

 <!-- data config file -->   <config>      <!-- keys-->   <foo value="bar"/>   <foo1 value="bar1"/>   <big_foo value="bar/bar.com"/>   <other value="f00"/> 

the query i'm using is:

select    col.value('foo1[0]', 'nvarchar(max)') value  ( select       cast((select top 1 xml_text dbo.xml_lookup)as xml)  col)x 

but returns null rather expected "bar1".

any idea i'm going wrong?

proper xpath be

col.value('(config/foo1)[1]/@value', 'nvarchar(max)') 

sql fiddle demo


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -