How to print an XML file?

 

hi,

i'm using VC#. I want to print out an existing XML file that it will pop up the openFileDialog and then the printDialog to let the user choose the printer.

The problem is that I want the print out to be in color (same as when you open and print the XML file from IE. )

Anyone can tell me how to do that or link to sample codes would be appriciated.

Thanks, 

 

ps. not sure if I am posting in the correct forum...



Answer this question

How to print an XML file?

  • WickedlNl

    hi,

    I am quite new to VC# and XML. can you explain more

    I'm not sure if my question is clear.

    My app. uses XMLserializer to create XML files and now I want it to be able to print out those XML files created .
    I tried to open the file and print it the same way as text file but the print out got only one line and all in black color. How can I print the XML in "nice" look ( I mean with the color ie. red for element and attribute name, black for the text in between and blue for "<", ">", "</", "/>"

    Thank you


  • CBColin

    is there any way to print more than one XML files with theShowPrintDialog() open only once
  • KumarG

    hi.

    I can transform the XML to HTML already but now I cannot find the way to print the HTML file.

    However, I have tried host the webbrowser in the application. now I can print out the XML file form that but I'm wondering is there is any way I can print more than one XML files with showPrintDialog() shown only once.

    Sorry to trouble u guys again...

    and also thank you in advance


  • Nabulaer

    Some ideas:

    1. You can host IE inside your app.

    2. IE to show XML runs some XSLT to convert it to HTML. You can do the same (almost). See http://www.xml.com/pub/a/2000/10/25/msie/index.html . I say almost because XSLT that is used in IE is pre-XSLT implementation and it is not supported in .NET. You can rewrite in on standard XSLT with the exception that you can't show DTD if XML file contains one. If you don't need DTD I'd recommend you use XslCompiledTransform to convert your XML to HTML or RTF or PS or whatever is convenient for you to print.



  • JEROMEMAS

    You may use the following stylesheet for colorizing XML:

    http://www.raleigh.ru/wiki/faq:xsltcolorer


  • Saurabh Mahajan

    Sorry.

    This is the different question and topic is not related to the subject of this forum.

    You may not find answer on this question here.



  • Dillon

    load it with the webbrowser control :D

  • Asif Shehzad

    I mean create an instance of XslCompiledTransform class. Load XSLT that does required formatting (you'd need to find it somewhere or compose it yourself) and transform you XML file to HTML file that has all colors and layout information you wish. (IE visualize XML this way.)

    This would help you if you know how to print HTML.



  • Emanuel Dejanu

     


  • How to print an XML file?