1

У меня проблема с парсингом HtmlDocument по какой то причине не могу войти в <td width="300px"> </td>

var doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml(@"<form action="""" method=""post"" name="""">
            <table cellpadding=""0"" cellspasing=""0"" id=""project"">
                <tr>
                    <td>
                        <div class=""panel"">
                            <img class=""avatar"" src="""">
                            <div class=""pos"">
                                <br>

                            </div>
                            <span class=""logo""></span>
                        </div>
                    </td>
                    <td style=""padding-right: 32px; width: 404px;"">
                        <input type=""text"" name=""login"" maxlength=""21"" placeholder="""" >
                    </td>
                    <td width=""300px"">
                        <input type=""hidden"" name=""token""value="""">
                        <input type=""hidden"" name=""secure"" value="""">
                        <input type=""hidden"" name=""id"" value="""">
                        <input type=""hidden"" name=""code"" value="""">
                        <input type=""hidden"" name=""hash"" value="""">
                        <span id=""buttonrate"" class=""button_blue"" onClick=""document.saverate.submit();""></span>
                    </td>
                </tr>
            </table>
        </form>");
textBox3.Text = doc.DocumentNode.SelectNodes("/form/table/tr/td[3]")[0].OuterHtml;

Я пробовал xPath "/form/table/tr/td[3]/td" но не получалось
Он должен вытянуть:

<input type="hidden" name="token"value="">
<input type="hidden" name="secure" value="">
<input type="hidden" name="id" value="">
<input type="hidden" name="code" value="">
<input type="hidden" name="hash" value="">
<span id="buttonrate" class="button_blue" onClick="document.saverate.submit();"></span>
0

1 ответ 1

1

Чтобы получить содержимое элемента используйте InnerHtml:

doc.DocumentNode.SelectNodes("/form/table/tr/td[3]")[0].InnerHtml;

OuterHtml включает в себя элемент и содержимое, InnerHtml — только содержимое.

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge you have read our privacy policy.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.