是否可以在InterxML中删除格式?
这是我的代码:
XmlNode test= doc.CreateElement("TEST");
test.InnerXml = "<p>" + "<i>" + "<b>" + "[" + TextBox5.Text + "]" + "</b>" + "</i>" + "
</p>";
目前将产生:
<TEST>
<p>
<i>
<b>[sometext]</b>
</i>
</p>
</TEST>
我该如何制作:
<TEST>
<p><i><b>[sometext]</b></i></p>
</TEST>
编辑:有趣的是,这种解决方法可以产生我需要的东西:
XmlNode test= doc.CreateElement("TEST");
XmlNode p = doc.CreateElement("p");
test.AppendChild(p);
p.AppendChild(doc.CreateWhitespace(""));
XmlNode i = doc.CreateElement("i");
p.AppendChild(i);
XmlNode b = doc.CreateElement("b");
b.InnerText = TextBox5.Text
i.AppendChild(b);
Here is my code:
XmlNode test= doc.CreateElement("TEST");
test.InnerXml = "<p>" + "<i>" + "<b>" + "[" + TextBox5.Text + "]" + "</b>" + "</i>" + "
</p>";
Currently it will produce:
<TEST>
<p>
<i>
<b>[sometext]</b>
</i>
</p>
</TEST>
How can i make it to produce:
<TEST>
<p><i><b>[sometext]</b></i></p>
</TEST>
Edit: Interestingly this workaround produce what i need:
XmlNode test= doc.CreateElement("TEST");
XmlNode p = doc.CreateElement("p");
test.AppendChild(p);
p.AppendChild(doc.CreateWhitespace(""));
XmlNode i = doc.CreateElement("i");
p.AppendChild(i);
XmlNode b = doc.CreateElement("b");
b.InnerText = TextBox5.Text
i.AppendChild(b);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论