October 8, 2019 at 11:52 am
Does anyone know how to get the value = "Avis" from this XML.
DECLARE @myDoc XML
DECLARE @ProdID VARCHAR(200)
SET @myDoc = '<?xml version="1.0" encoding="UTF-8"?>
<bookstore>
<book category="web">
<title lang="en"> Kick Start</title>
<author>James McGovern</author>
</book>
</bookstore>'
SELECT @myDoc.value('/bookstore/book/span/@class', 'varchar(200)')
October 8, 2019 at 12:20 pm
It is not possible, as the value "Avis" does not exist in the sample data
October 8, 2019 at 12:40 pm
It is not possible, as the value "Avis" does not exist in the sample data
Strange I pasted it and it doesn't show in my post. I will pasting it again.
DECLARE @myDoc XML
DECLARE @ProdID VARCHAR(200)
SET @myDoc = '<?xml version="1.0" encoding="UTF-8"?>
<bookstore>
<book category="web">
<title lang="en"> Kick Start</title>
<author>James McGovern</author>
</book>
</bookstore>'
SELECT @myDoc.value('/bookstore/book/span/@class', 'varchar(200)')
October 8, 2019 at 12:41 pm
I have attached it. It looks like it doesn't show when i paste it.
October 8, 2019 at 12:44 pm
It is not possible, as the value "Avis" does not exist in the sample data
I usually have a bad reaction when people use absolutes. Never say never
DECLARE @myDoc XML;
SET @myDoc
= '<?xml version="1.0" encoding="UTF-8"?>
<bookstore>
<book category="web">
<title lang="en"> Kick Start</title>
<author>James McGovern</author>
aaaaaa
</book>
</bookstore>';
DECLARE @Str1 VARCHAR(500) = CAST(@myDoc AS VARCHAR(500));
SELECT SUBSTRING(@Str1, 19, 1) + SUBSTRING(@Str1, 87, 1) + SUBSTRING(@Str1, 35, 1) + SUBSTRING(@Str1, 6, 1);
October 8, 2019 at 1:05 pm
Thanks you so much!
October 8, 2019 at 1:19 pm
Due to the clash of you div names with the web page, I am not recreating the actual xml here.
This should also get what you are looking for.
SELECT @myDoc.value( '(bookstore/book/div)[1]/@data-store-name', 'varchar(200)' );
Viewing 7 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy