Quantcast
Channel: htmlagilitypack Forum Rss Feed
Viewing all articles
Browse latest Browse all 450

New Post: Can i modify innerText of HtmlNote ?

$
0
0
i have a simple html code
<p style="background-color:#FFFFFF;" align="center">CHAPTER XIII</p>
<p style="background-color:#FFFFFF;" align="center"><span class"font0">AUSTRALIAN AIRMEN IN FRANCE</span></p>
i want to remove all childnode in <p> tag and keep innerText of <p> as plaint text
i use this code
foreach (HtmlNode note in doc.DocumentNode.SelectNodes("//p"))
            {       
                
              string innerText = string.Empty;
                foreach (HtmlNode childnode in note.ChildNodes)
                {
                    innerText += childnode.InnerText;
                    note.RemoveAllChildren();
                    note.InnerText = innerText;
                }
                try
                {                    
                    note.Attributes["style"].Remove();
                    note.Attributes["align"].Remove();
                }
                catch { ; }
            }
but it not work, because note.InnerText is ReadOnly.
So, how do i can change the innerText of <p>.
Thanks for read!

Viewing all articles
Browse latest Browse all 450

Trending Articles