在C#中将XmlElement输出到控制台 [英] output XmlElement to Console in C#

查看:241
本文介绍了在C#中将XmlElement输出到控制台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿伙计们,我如何在C#中将序列化的XmlElement输出到Console。这个java代码是这样的:


Hey guys, how can i output serialized XmlElement to Console in C#. This java code does it

private void printXML(Element lobjElement) {
/* This function is used for debugging purposes. Its a utilityfunction */
 try{
     String lstrRRXString;
     XMLSerializer lobjSer1 = new XMLSerializer(System.out,null);
      lobjSer1.serialize(lobjElement);
     } catch(Exception e) {
      System.out.println("Error in printXML of RecordObject "  + e.getMessage());
   }
}





感谢您的帮助



Thanks for the help

推荐答案

Hello Rudolph,



请查看 this [ ^ ] MSDN文档。您需要使用 XmlTextWriter [ ^ ]类来完成此任务。



问候,
Hello Rudolph,

Please have a look at this[^] MSDN documentation. You need to use XmlTextWriter[^] class to accomplish this.

Regards,


XmlElement 类实现了一个类型的属性 string 名为 OuterXml 。您可以使用以下内容:
The XmlElement class implements one property of type string called OuterXml. You can use somthing like:
Console.WriteLine( TheXmlElement.OuterXml );

将元素的Xml文本打印到标准(控制台)输出。 TheXmlElement XmlElement 实例。

to print out the element's Xml text to the standard (console) output. TheXmlElement is the XmlElement instance.


这篇关于在C#中将XmlElement输出到控制台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆