Help converting to C#

  • Thread starter Patrick Olurotimi Ige
  • Start date
P

Patrick Olurotimi Ige

Any help to conver the code below to VB.Net?

Function getXML(ByVal sourceFile As String)
Dim myRequest As System.Net.WebRequest =
System.Net.WebRequest.Create(sourceFile)
Dim myResponse As System.Net.WebResponse =
myRequest.GetResponse()
Dim myReader As System.Xml.XmlTextReader = New
System.Xml.XmlTextReader(myResponse.GetResponseStream())
Dim doc As System.Xml.XmlDocument = New System.Xml.XmlDocument
doc.Load(myReader)
getXML = doc
myResponse.Close()
myReader.Close()
End Function

Thanks alot
 
G

Guest

Our Instant C# VB.NET to C# converter produces:

public object getXML(string sourceFile)
{
object tempgetXML = null;
System.Net.WebRequest myRequest =
System.Net.WebRequest.Create(sourceFile);
System.Net.WebResponse myResponse = myRequest.GetResponse();
System.Xml.XmlTextReader myReader = new
System.Xml.XmlTextReader(myResponse.GetResponseStream());
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.Load(myReader);
tempgetXML = doc;
myResponse.Close();
myReader.Close();
return tempgetXML;
}

Note that your original VB function implicitly returns 'Object'.

--
David Anton
www.tangiblesoftwaresolutions.com
Home of:
Instant C#: VB.NET to C# Converter
Instant VB: C# to VB.NET Converter
Instant J#: VB.NET to J# Converter
 
P

Patrick Olurotimi Ige

Thanks David for the reply.
Actually i'm using the function in relating to page_load below.
But i get the error on this line at:-
myXml.Document =
getXML("http://headlinefeeds.news.com.au/servlet/Controller?controllerac
tion=feedaction&feedid=31&count=10&typeid=4");

Its says you can't implicitly convert type 'object' to
System.Xml.XmlDocument.
Any help?




private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
myXml.Document =
getXML("http://headlinefeeds.news.com.au/servlet/Controller?controllerac
tion=feedaction&feedid=31&count=10&typeid=4");

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top