如何删除标签之间的换行符?
假设我有这段代码:
XmlNode counsel = doc.CreateElement("COUNSELS");
XmlNode p = doc.CreateElement("p");
counsel.AppendChild(p);
XmlNode b = doc.CreateElement("b");
p.AppendChild(b);
b.InnerText = "Counsel:";
它将输出:
<COUNSELS>
<p>
<b>Counsel:</b>
</p>
</COUNSELS>
我该怎么做才能实现这一点:
<COUNSELS>
<p><b>Counsel:</b></p>
</COUNSELS>
如果我在写这篇文章时犯了任何错误,请纠正我。
Let say i have this code:
XmlNode counsel = doc.CreateElement("COUNSELS");
XmlNode p = doc.CreateElement("p");
counsel.AppendChild(p);
XmlNode b = doc.CreateElement("b");
p.AppendChild(b);
b.InnerText = "Counsel:";
and it will output:
<COUNSELS>
<p>
<b>Counsel:</b>
</p>
</COUNSELS>
what can i do to achieve this:
<COUNSELS>
<p><b>Counsel:</b></p>
</COUNSELS>
correct me if i made any mistake on writing this post.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于OP稳固的正则替换是可以接受的。我可以使用两个简单的替代品。
输出
您可以遵循模式以替换其他标签周围的空间,或者使用更高级的单个时间替换,这一切都取决于您的实际需求和技能。
Since the OP comfirms regex replace is acceptable. I can use two simple replaces.
output
You can follow the pattern to replace space around other tags, or use more advanced single time replace, all depend on your actual requirement and skills.