cyrus2500 cyrus2500 - 1 month ago 10
SQL Question

How to Fix error in this example in sql?

how to get node "-all_models=1-4.htm" in sql this example?
this is my code:

<div class="models_selector_block" >
<DIV class="msb_item">
<a class="ser_active" href="index-1476.htm" tppabs="http://www.laptopscreen.com/English/series/Acer/ASPIRE/">ASPIRE</a> </DIV> <DIV class="msb_item"> <a class="ser_selector" href="index-1479.htm" tppabs="http://www.laptopscreen.com/English/series/Acer/EXTENSA/">EXTENSA</a> </DIV> <DIV class="msb_item"> <a class="ser_selector" href="index-1482.htm" tppabs="http://www.laptopscreen.com/English/series/Acer/FERRARI/">FERRARI</a>
</DIV>
<DIV class="msb_item">
<a class="ser_selector" href="index-1485.htm" tppabs="http://www.laptopscreen.com/English/series/Acer/ICONIA/">ICONIA</a>
</DIV>
<DIV class="msb_item">
<a class="ser_selector" href="index-1488.htm" tppabs="http://www.laptopscreen.com/English/series/Acer/TRAVELMATE/">TRAVELMATE</a>
</DIV>
<DIV class="msb_item">
<a class="ser_selector" href="index-1491.htm" tppabs="http://www.laptopscreen.com/English/series/Acer/Other Acer Models/">Other Acer Models</a>
</DIV>

</div>
<h2 class="mbp_15_h2" style="font-size: 2.3em; text-align:center;text-transform:uppercase">SELECT FIRST CHARACTER OF YOUR ASPIRE LAPTOP MODEL</h2>
<div style="text-align:center;">
<div>
<span style="font-size:1.8em;">Example: if you have <span style="padding:1px;">ASPIRE&amp;nbsp;&amp;nbsp;</span><span style="padding:1px;border: 1px solid red;height:200px">
<div style="display:inline-block;height:60px;width:1em;background:url("char_arrow.png")/*tpa=http://www.laptopscreen.com/a_images/char_arrow.png*/ no-repeat center top;">4
</div>
</span>
<span style="padding:1px;">740G-334G32Mi</span>, click on 4 button below:</span>
<span style="color:#696969;font-size:1.7em;padding:1px;">&amp;nbsp;&amp;nbsp;&amp;nbsp;
</span>
</div>
</div>
<div style="height:25px;">
</div>
<style type="text/css">a.button_like{text-decoration:none;margin:15px;width:90px;height:90px;padding-top:14px;text-align:center;font-size:3.8em;color:white;text-shadow: 1px 1px #777;display:inline-block;background:url("char_bckg.png")/*tpa=http://www.laptopscreen.com/a_images/char_bckg.png*/ no-repeat left top; }a.button_like:hover{background:url("char_bckg_h.png")/*tpa=http://www.laptopscreen.com/a_images/char_bckg_h.png*/ no-repeat left top;}</style>
<div style="overflow:hidden;padding-left:250px;padding-right:250px;text-align:left;">
<a class="button_like" href="-letter=1.htm" tppabs="http://www.laptopscreen.com/English/series/Acer/ASPIRE/?letter=1">1</a>
<a class="button_like" href="-letter=2.htm" tppabs="http://www.laptopscreen.com/English/series/Acer/ASPIRE/?letter=2">2</a>
<a class="button_like" href="-letter=3.htm" tppabs="http://www.laptopscreen.com/English/series/Acer/ASPIRE/?letter=3">3</a>
<a class="button_like" href="-letter=4.htm" tppabs="http://www.laptopscreen.com/English/series/Acer/ASPIRE/?letter=4">4</a>
<a class="button_like" href="-letter=5.htm" tppabs="http://www.laptopscreen.com/English/series/Acer/ASPIRE/?letter=5">5</a>
<a class="button_like" href="-letter=6.htm" tppabs="http://www.laptopscreen.com/English/series/Acer/ASPIRE/?letter=6">6</a>
<a class="button_like" href="-letter=7.htm" tppabs="http://www.laptopscreen.com/English/series/Acer/ASPIRE/?letter=7">7</a>
<a class="button_like" href="-letter=8.htm" tppabs="http://www.laptopscreen.com/English/series/Acer/ASPIRE/?letter=8">8</a>
<a class="button_like" href="-letter=9.htm" tppabs="http://www.laptopscreen.com/English/series/Acer/ASPIRE/?letter=9">9</a>
<a class="button_like" href="-letter=A.htm" tppabs="http://www.laptopscreen.com/English/series/Acer/ASPIRE/?letter=A">A</a>
<a class="button_like" href="-letter=B.htm" tppabs="http://www.laptopscreen.com/English/series/Acer/ASPIRE/?letter=B">B</a>
<a class="button_like" href="-letter=C.htm" tppabs="http://www.laptopscreen.com/English/series/Acer/ASPIRE/?letter=C">C</a>
<a class="button_like" href="-letter=D.htm" tppabs="http://www.laptopscreen.com/English/series/Acer/ASPIRE/?letter=D">D</a>
<a class="button_like" href="-letter=E.htm" tppabs="http://www.laptopscreen.com/English/series/Acer/ASPIRE/?letter=E">E</a>
<a class="button_like" href="-letter=F.htm" tppabs="http://www.laptopscreen.com/English/series/Acer/ASPIRE/?letter=F">F</a>
<a class="button_like" href="-letter=I.htm" tppabs="http://www.laptopscreen.com/English/series/Acer/ASPIRE/?letter=I">I</a>
<a class="button_like" href="-letter=J.htm" tppabs="http://www.laptopscreen.com/English/series/Acer/ASPIRE/?letter=J">J</a>
<a class="button_like" href="-letter=K.htm" tppabs="http://www.laptopscreen.com/English/series/Acer/ASPIRE/?letter=K">K</a>
<a class="button_like" href="-letter=M.htm" tppabs="http://www.laptopscreen.com/English/series/Acer/ASPIRE/?letter=M">M</a>
<a class="button_like" href="-letter=N.htm" tppabs="http://www.laptopscreen.com/English/series/Acer/ASPIRE/?letter=N">N</a>
<a class="button_like" href="-letter=O.htm" tppabs="http://www.laptopscreen.com/English/series/Acer/ASPIRE/?letter=O">O</a>
<a class="button_like" href="-letter=P.htm" tppabs="http://www.laptopscreen.com/English/series/Acer/ASPIRE/?letter=P">P</a>
<a class="button_like" href="-letter=Q.htm" tppabs="http://www.laptopscreen.com/English/series/Acer/ASPIRE/?letter=Q">Q</a>
<a class="button_like" href="-letter=R.htm" tppabs="http://www.laptopscreen.com/English/series/Acer/ASPIRE/?letter=R">R</a>
<a class="button_like" href="-letter=S.htm" tppabs="http://www.laptopscreen.com/English/series/Acer/ASPIRE/?letter=S">S</a>
<a class="button_like" href="-letter=T.htm" tppabs="http://www.laptopscreen.com/English/series/Acer/ASPIRE/?letter=T">T</a>
<a class="button_like" href="-letter=V.htm" tppabs="http://www.laptopscreen.com/English/series/Acer/ASPIRE/?letter=V">V</a>
<a class="button_like" href="-letter=Z.htm" tppabs="http://www.laptopscreen.com/English/series/Acer/ASPIRE/?letter=Z">Z</a>
</div>
<div style="text-align:center">
<span style="font-size:16px; font-weight:normal;">If not sure, <a href="-all_models=1-4.htm" tppabs="http://www.laptopscreen.com/English/series/Acer/ASPIRE/?all_models=1">see all Acer ASPIRE models</a> or read <a href="javascript:if(confirm(%27http://www.laptopscreen.com/laptopscreen_viewer.php?edit_language=English&amp;view_article=1244226750&amp;height=500&amp;width=800 \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a path excluded by the site\%27s Robot Exclusion parameters. (Teleport Pro\%27s compliance with this system is optional; see the Project Properties, Netiquette page.) \n\nDo you want to open it from the server?%27))window.location=%27http://www.laptopscreen.com/laptopscreen_viewer.php?edit_language=English&amp;view_article=1244226750&amp;height=500&amp;width=800%27" tppabs="http://www.laptopscreen.com/laptopscreen_viewer.php?edit_language=English&amp;view_article=1244226750&amp;height=500&amp;width=800" title="" class="thickbox">Locating your laptop model number</a> article.</span>
</div>
<div class="tupizm"> &amp;nbsp;
</div>
<div id="sub_footer"></div>'


SQL:

SELECT
t.v.value('@href','nvarchar(max)') as [URL Local],
t.v.value('@tppabs','nvarchar(max)') as [URL Site]
FROM @htmlXML.nodes('div[5]/span/a[1]') as t(v)


Error:


Msg 9410, Level 16, State 1, Procedure SP_Gethref, Line 20

XML parsing: line 20, character 81, whitespace expected

Answer

The error message says it all: You have invalid XML. It even gives the the line and character position of the error. It is this here:

<div style="display:inline-block;height:60px;width:1em;background:url("char_arrow.png")/*tpa=http://www.laptopscreen.com/a_images/char_arrow.png*/ no-repeat center top;">

You cannot use double quotes inside double quotes of a an xml attribute. Use single quotes instead inside inline css:

<div style="display:inline-block;height:60px;width:1em;background:url('char_arrow.png')/*tpa=http://www.laptopscreen.com/a_images/char_arrow.png*/ no-repeat center top;">
Comments