Click here to Skip to main content
15,914,481 members
Please Sign up or sign in to vote.
2.33/5 (2 votes)
See more:
Hey guys, how can i output serialized XmlElement to Console in C#. This java code does it

Java
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
Posted

Hello Rudolph,

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

Regards,
 
Share this answer
 
The XmlElement class implements one property of type string called OuterXml. You can use somthing like:
C#
Console.WriteLine( TheXmlElement.OuterXml );
to print out the element's Xml text to the standard (console) output. TheXmlElement is the XmlElement instance.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900