Sign In/My Account | View Cart  
advertisement

Article:
 Pull Parsing in C# and Java
Subject: XML to HTML
Date: 2003-01-22 08:39:35
From: Niel Bornstein
Response to: XML to HTML

I guess I should have made it clearer that the program takes as an argument the URL of the file to parse. The error you got indicates that there were no arguments passed to the Main method. To invoke the program to read the XML at the URL http://xmlhack.com/rss.php, you should enter the following on the command line: "RSSReader http://xmlhack.com/rss.php".


As to your second question, to take the input from a file instead of an HTTP URL, you would need to change some of the code inside the try/catch block of the Main method. It would need to look something like this:


string url = args[0];
XmlTextWriter writer = new XmlTextWriter(Console.Out);
writer.Formatting = Formatting.Indented;
XmlTextReader reader = new XmlTextReader(url);
reader.XmlResolver = null; // ignore the DTD
reader.WhitespaceHandling = WhitespaceHandling.None;
rssreader.RSSToHtml(reader, writer);


Invoke the program, passing in the filename as the argument. This would also work for HTTP URLs without a web proxy, by the way, as the XmlTextReader knows how to read a file directly from an HTTP URL as well as a local filename.


No Previous Message Previous Message Move up to Parent Message Up Next Message No Next Message


Sponsored By: