Can one force XMLWriter to write elements in single quotes?

寵の児 提交于 2019-12-10 20:07:06

问题


Here's my code:

var ptFirstName = tboxFirstName.Text;
writer.WriteAttributeString("first",ptFirstName);

note that ptFirstName will end up in double quotes even if I use

ptFirstName = ptFirstName.Replace("\"","'"); 

This does not work either since the writer will still force double quotes in my file as follows:

when in fact I need (don't ask me why - it's a long story...)


回答1:


Yes, you can set what character is used for quotes by setting the XmlTextWriter.QuoteChar property. See http://msdn.microsoft.com/en-ca/library/system.xml.xmltextwriter.quotechar.aspx for details.

But this means you have to create an XmlTextWriter object for this to work.



来源:https://stackoverflow.com/questions/15457011/can-one-force-xmlwriter-to-write-elements-in-single-quotes

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!