格式化XmlTextWriter输出 [英] Formatting XmlTextWriter Output
问题描述
//我想要这种格式...
< rss version =" 2.0"
xmlns:dc =" http:// purl。 org / dc / elements / 1.1 /"
xmlns:media =" http://search.yahoo.com/mrss/">
WriteStartElement用于rss元素,并使用
WriteAttributeString方法进行扩展,该方法输出版本和命名空间
属性。有人可以告诉我如何格式化输出如上所示吗?
<%= Clinton Gallagher
NET csgallagher AT metromilwaukee.com
URL http://clintongallagher.metromilwaukee.com/
// I want this format...
<rss version="2.0"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:media="http://search.yahoo.com/mrss/">
The WriteStartElement is used for the rss element and extended using the
WriteAttributeString method which outputs the version and namespace
attributes. Can someone tell me how to format the output as shown above?
<%= Clinton Gallagher
NET csgallagher AT metromilwaukee.com
URL http://clintongallagher.metromilwaukee.com/
推荐答案
clintonG写道:
clintonG wrote:
//我想要这种格式...
< rss version =" 2.0"
xmlns:dc =" http://purl.org/dc/elements/1.1/"
xmlns:media =" http://search.yahoo.com/mrss/">
WriteStartElement用于rss元素并使用
WriteAttributeString方法输出版本和命名空间
属性。有人能告诉我如何格式化输出如上所示?
// I want this format...
<rss version="2.0"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:media="http://search.yahoo.com/mrss/">
The WriteStartElement is used for the rss element and extended using the
WriteAttributeString method which outputs the version and namespace
attributes. Can someone tell me how to format the output as shown above?
使用.NET 2.0,你可以使用
XmlWriterSettings writerSettings = new XmlWriterSettings();
writerSettings.NewLineOnAttributes = true;
writerSettings.Indent = true;
然后使用这些设置来创建你的作家,例如
using(XmlWriter writer = XmlWriter.Create (@" file.xml",writerSettings))
{
//在这里写XML
}
这不会完全给出你在上面指定的内容我认为但是在
中,每个属性都应该写在自己的一行上。
-
Martin Honnen --- MVP XML
http://javaScript.FAQTs.com/
这是可以使用的感谢...
<%=克林顿
" Martin Honnen" < ma ******* @ yahoo.dewrote in message
news:ur ************* @ TK2MSFTNGP05.phx.gbl ...
That''s something to work with thanks...
<%= Clinton
"Martin Honnen" <ma*******@yahoo.dewrote in message
news:ur*************@TK2MSFTNGP05.phx.gbl...
clintonG写道:
clintonG wrote:
> //我想要这种格式......
< ; rss version =" 2.0"
xmlns:dc =" http://purl.org/dc/elements/1.1/"
xmlns:media =" http:// search .yahoo.com / mrss /">
WriteStartElement用于rss元素,并使用
WriteAttributeString方法进行扩展,该方法输出版本和名称空间
属性。有人能告诉我如何格式化输出如上所示?
>// I want this format...
<rss version="2.0"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:media="http://search.yahoo.com/mrss/">
The WriteStartElement is used for the rss element and extended using the
WriteAttributeString method which outputs the version and namespace
attributes. Can someone tell me how to format the output as shown above?
使用.NET 2.0,您可以使用
XmlWriterSettings writerSettings = new XmlWriterSettings();
writerSettings.NewLineOnAttributes = true;
writerSettings.Indent = true;
然后使用这些设置来创建你的作家,例如
using(XmlWriter writer = XmlWriter.Create (@" file.xml",writerSettings))
{
//在这里写XML
}
这不会完全给出你在上面指定的内容我认为但是在
中,每个属性都应该写在自己的一行上。
-
Martin Honnen --- MVP XML
http://javaScript.FAQTs.com/
很棒!
包含XmlWriterSettings对象将不允许任何字符串
包含冒号的参数。
//这将是现在ba rf ...
writer.WriteAttributeString(" xmlns:dc"," http://purl.org/dc/elements/1.1/");
>
<%= Clinton
" Martin Honnen" < ma ******* @ yahoo.dewrote in message
news:ur ************* @ TK2MSFTNGP05.phx.gbl ...
Amazing!
The inclusion of the XmlWriterSettings object will not allow any string
arguments that contain a colon.
// this will now barf...
writer.WriteAttributeString("xmlns:dc", "http://purl.org/dc/elements/1.1/");
<%= Clinton
"Martin Honnen" <ma*******@yahoo.dewrote in message
news:ur*************@TK2MSFTNGP05.phx.gbl...
clintonG写道:
clintonG wrote:
> //我想要这种格式......
< ; rss version =" 2.0"
xmlns:dc =" http://purl.org/dc/elements/1.1/"
xmlns:media =" http:// search .yahoo.com / mrss /">
WriteStartElement用于rss元素,并使用
WriteAttributeString方法进行扩展,该方法输出版本和名称空间
属性。有人能告诉我如何格式化输出如上所示?
>// I want this format...
<rss version="2.0"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:media="http://search.yahoo.com/mrss/">
The WriteStartElement is used for the rss element and extended using the
WriteAttributeString method which outputs the version and namespace
attributes. Can someone tell me how to format the output as shown above?
使用.NET 2.0,您可以使用
XmlWriterSettings writerSettings = new XmlWriterSettings();
writerSettings.NewLineOnAttributes = true;
writerSettings.Indent = true;
然后使用这些设置来创建你的作家,例如
using(XmlWriter writer = XmlWriter.Create (@" file.xml",writerSettings))
{
//在这里写XML
}
这不会完全给出你在上面指定的内容我认为但是在
中,每个属性都应该写在自己的一行上。
-
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
这篇关于格式化XmlTextWriter输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!