0
나는 예를 들어, HTML 문서와 중첩 된 DIV를 얻을 필요가 :Xpath를 사용하여 중첩 된 div를 얻는 방법?
<div id="maindiv>
<div id='firstdiv'>
</div>
<div id="otherid">
<div id="anotherdiv"><div id="divid"></div>
</div>
</div>
내가 anotherdiv
의 내용을 얻을 필요가있다. maindiv
이 주 문서 내에 얼마나 깊고 anotherdiv
의 깊이가 maindiv
일 수 있는지 잘 모르겠습니다.
var doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml(content);
var main = doc.GetElementbyId("maindiv").InnerHtml;
doc.LoadHtml(main);
var another = doc.GetElementbyId("anotherdiv");
이 잘 작동합니다. 그러나 XPath를 사용하여 필요한 div를 얻는 더 좋은 방법이 있습니까?
/maindiv/otherid/텍스트를 사용할 수 있습니다 – Oscar