Click here to Skip to main content
15,888,286 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
////form>
HTML
</tr>
</table>
<table border=1 width="100%%" class="x2" cellspacing=0>
	<tr class=xhead align="center">
		<td>Line</td>
		<td>Entrance line: Number - Description, Duration</td>
		<td>Target line: Number - Description, Duration</td>
		<td>Hold line: Number - Description, Duration</td>
		<td>Status</td>
		<td>Conference</td>
	</tr>
<tr align="center">
	<td>0</td>
	<td>0595100131 - 0595100131, 00:00:39</td>
	<td>2550055 - 255005~, 00:00:39</td>
	<td>&nbsp;</td>
	<td>Connect             </td>
	<td>&nbsp;</td>
</tr>





</body>
</html>
here is html code
and i am parsing using
C#
DECLARE @html xml =(SELECT  Gap FROM  dbo.Test2)

-- code to get extract data from the HTML
SELECT	sale_date = xx.value('(./td/text())[1]','varchar(100)'),
		sale_amt = xx.value('(./td/text())[2]','varchar(100)')
FROM (values(@html)) t1(x)
CROSS APPLY x.nodes('//table/tr') t2(xx);

this code and i have error
C#
Msg 9436, Level 16, State 1, Line 1
XML parsing: line 2, character 6, end tag does not match start tag

help me guys
Posted
Updated 21-Jan-16 4:06am
v2
Comments
[no name] 21-Jan-16 12:04pm    
Your content XML is looking HTML code. And your trying to get value from it, why? It's ok, it is your requirement. But XML content is not correct. Somewhere double quote is missing and somewhere closing tag is missing. Correct it and then execute your query.

Your xml is invalid, you have closing tags to start with, you open a table tag but close it with a body tag.

If these issues are with the way you have formatted your question then use the Improve Question button to post the actual xml you are using.
 
Share this answer
 
HTML is not XML.

If your input was valid XHTML, then you could parse it as XML.

Since the input isn't XHTML, you cannot parse it as XML. You need to use an HTML parser like AngleSharp[^] or Html Agility Pack[^].

It's not clear whether either of these would work in a SQLCLR project. If not, you'll have to move your HTML processing into your .NET code.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900