from xmlnode My XML might look like this:

First Text
Second Text

Loading an xml file going...">

Remove <br/"> from xmlnode

My XML might look like this:

<div>
    <p>
       First Text
        <br/>
       Second Text
    </p>
</div>

      

Loading an xml file going through all nodes with the following code:

XmlDocument doc = new XmlDocument();
doc.Load(filepath);

foreach (XmlNode row in doc.SelectNodes("/div/p"))
{
    string subtext = row.InnerText;
    richtextbox.AppendText(subtext + "\n");
}

      

The result will always look like this:

First TextSecond Text

      

Now the problem is that there is no space (or even a line break) between the first and second text. So, is there a way to replace this with a <br/>

space / line?

+3


source to share


1 answer


You can use the following XPath:

doc.SelectNodes("/div/p/text()")

      



It provides you with two text nodes before and after the tag br

.

0


source







All Articles