#html #sql
#HTML #sql
Вопрос:
как получить узел «-all_models=1-4.htm » в sql этот пример? это мой код:
<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;">ASPIREamp;amp;nbsp;amp;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;amp;nbsp;amp;amp;nbsp;amp;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('http://www.laptopscreen.com/laptopscreen_viewer.php?edit_language=Englishamp;amp;view_article=1244226750amp;amp;height=500amp;amp;width=800 nnThis file was not retrieved by Teleport Pro, because it is addressed on a path excluded by the site's Robot Exclusion parameters. (Teleport Pro's compliance with this system is optional; see the Project Properties, Netiquette page.) nnDo you want to open it from the server?'))window.location='http://www.laptopscreen.com/laptopscreen_viewer.php?edit_language=Englishamp;amp;view_article=1244226750amp;amp;height=500amp;amp;width=800'" tppabs="http://www.laptopscreen.com/laptopscreen_viewer.php?edit_language=Englishamp;amp;view_article=1244226750amp;amp;height=500amp;amp;width=800" title="" class="thickbox">Locating your laptop model number</a> article.</span>
</div>
<div class="tupizm"> amp;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)
Ошибка:
Сообщение 9410, уровень 16, состояние 1, процедура SP_Gethref, строка 20
Синтаксический анализ XML: строка 20, символ 81, ожидаемый пробел
Комментарии:
1. Не понятно, как вы использовали SQL непосредственно в HTML? Могу я узнать, какой у вас внутренний язык программирования?
2. Вы уверены, что ваш HTML правильно сформирован (например, каждый открытый тег имеет соответствующий закрывающий тег)?
3. @kermani — с помощью c # выберите специальный контент
4. @TimBiegeleisen —— да
Ответ №1:
В сообщении об ошибке все сказано: У вас неверный XML. Он даже выдает строку и позицию символа ошибки. Это здесь:
<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;">
Вы не можете использовать двойные кавычки внутри двойных кавычек атрибута xml. Вместо этого используйте одинарные кавычки внутри встроенного 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;">