开发者

formatting xml with xmltextwriter

I am creating xml docs using xmltextwriter ( by the way I was just introduced to xslt which I am now learning to adopt rather) and having problems getting the xml to indent correctly.

Here is what I would like the format to be

<htmltext> CData[.......<br>
   <img  src=".......">
   <a href="........"</a><br>
   ...some text here from a string....<br>
   ...some other text here froma string>
</htmltext>

here is what I have tried:

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.WriteElementSt开发者_Python百科ring("", htitle)
xwriter.WriteElementString("", "<br>")
xwriter.WriteString(Environment.NewLine)
xwriter.WriteElementString("", hsubtitle)
xwriter.WriteElementString("", "<br>")
xwriter.WriteString(Environment.NewLine)
xwriter.WriteElementString("", htext)
xwriter.WriteEndElement()

not sure where to go from here. Appreciate any responses


found a workaround and just converted all into a string.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜