我正在使用xmltextwriter创建xml文档(就像我刚刚介绍的xslt一样,我现在正在学习采用它)并且在使xml正确缩进时遇到了问题。
这就是我想要的格式
<htmltext> CData[.......<br>
<img src=".......">
<a href="........"</a><br>
...some text here from a string....<br>
...some other text here froma string>
</htmltext>
这是我尝试过的:
xwriter.WriteStartElement("htmltext")
xwriter.WriteCData(hcontent)
xwriter.WriteElementString("", "<br>")
xwriter.WriteString(Environment.NewLine)
xwriter.Indentation = 2
xwriter.WriteElementString("img", "")
xwriter.WriteStartAttribute("src", himage)
xwriter.WriteEndAttribute()
xwriter.WriteString(Environment.NewLine)
xwriter.WriteElementString("a", "")
xwriter.WriteStartAttribute("href", hlinks)
xwriter.WriteEndAttribute()
xwriter.WriteElementString("", htitle)
xwriter.WriteElementString("", "<br>")
xwriter.WriteString(Environment.NewLine)
xwriter.WriteElementString("", hsubtitle)
xwriter.WriteElementString("", "<br>")
xwriter.WriteString(Environment.NewLine)
xwriter.WriteElementString("", htext)
xwriter.WriteEndElement()
不确定从哪里开始。感谢任何回复
答案 0 :(得分:0)
找到了一种解决方法,只是将其全部转换为字符串。