HtmlAgilityPack giving exception "Multiple node elments can't be created."

html-agility-pack

Question

I am removing certain placeholder input tags and replacing them with HTML. The code snippet I'm using to construct an HTML node is shown below. However, when there aren't any multiple nodes, it gives the error "Multiple node elements can't be formed."

string tempString = "<p style="margin-left:0px;margin-right:0px;text-indent:0px;text-align:justify;">(c)<span style='display: inline-block; width: 30px; min-width: 30px;'>&nbsp;</span><span class='noCount4'> </span>paragraph <span class="Ellh_">(a)<span class='noCount-44'> </span>&nbsp;of Clause <span class='noCount-48'> </span><span class="Ellj_">25.3<span class='noCount-44'> </span>&nbsp;(<span class='noCount-49'></span> </span><i>Other obligations</i>) as a result of an <span class="El2d_">Obligor </span>failing to comply with its obligations under Clause <span class="Ellm_">24.22<span class='noCount-44'> </span>&nbsp;(<span class='noCount-50'></span> </span><i><span class="El2e_">Financial Indebtedness</i></span>);<span class='noCount-1'> </span></span></p>"

HtmlNode tempNode = HtmlNode.CreateNode(tempString);

But HtmlNode.CreateNode(tempString) "Multiple node elements can't be formed" error message.

Can somebody tell me what's wrong with this situation?

1
5
1/25/2018 3:13:48 AM

Popular Answer

Although it is true that "many node elements cannot be produced," this statement might be misleading. HtmlNode. CreateNode() only allows HTML with one external container node, or single node HTML.

Adjust this...

<p>
    blah blah...
</p> 
<span>
    More stuff... 
</span>

I'm into this

<div>
   <p>
      blah blah...
   </p>
   <span>
      More stuff...
   </span>
</div>
5
4/18/2018 1:54:52 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow