How to select data from xml data

Hi all,

m‌y front end appliction store the data in xml data type but we select the data in query.
m‌y xml data like

F‌inaly we select the data like

s‌eelct nodename(block/item),url,type‌‌‌‌,title

P‌lease help....asap‌

provide xml ...asap

that is a very blank xml :rofl::robot:

Copy the xml to notepad then copy it from notepad to this web site.

i am doing same thing but not post in website

post a screen shot of it

and now please post the final result you want queried out of this xml?

eclare @fakenews as xml = 
'<searchResult>
	<section col="main">
		<block type="topStories" url="">
			<item url="https://en.m.wikipedia.org/wiki/Donal_trump" />
		</block>
		<item url="https://en.m.wikipedia.org/wiki/Donal_trump" />
	</section>
	<section col="right" />
</searchResult>'

select x.v.value('item[1]/@url', 'varchar(150)') as deep_state
from @fakenews.nodes('/searchResult/section/block') x(v)

seelct nodename(block/item),url,type,title

which url do you want? url from or url from item because I see two item nodes
one under block and one under section?

declare @fakenews as xml = 
'<searchResult>
	<section col="main">
		<block type="topStories" url="">
			<item url="https://en.m.wikipedia.org/wiki/Saadam_Hussein" />
		</block>
		<block type="knowledgeGraph" url="" />
		<block type="relatedSearches" url="">
			<item url="" title="donal trump twitter" />
		</block>
		<item url="https://en.m.wikipedia.org/wiki/Donal_trump" />
	</section>
	<section col="right" />
</searchResult>'

select x.y.value('../item[1]/@url', 'varchar(150)') as section_item_url,  
	   x.y.value('@type', 'varchar(150)') as section_block_type,
	   x.y.value('item[1]/@url', 'varchar(150)') as section_block_item_url

  from @fakenews.nodes('/searchResult/section/block') x(y)
 

my xmldata like


but result selection likeaaaa

here i tam urls and title are missing....please check once

and also each block is multiple urls