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);
The absence of evidence is not evidence of absence.
Martin Rees
You can lead a horse to water, but a pencil must be lead.
Stan Laurel
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 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply