ASP.net XML getting and parsing

I need something to read a XML string and grab attributes from it in asp.net
The source of the XML is a local script, but the script need to be executed:
www.mysite.com/ascript.asp

As you'll notice the XML source is also classic asp, not .net so this is the only realy way i can do this.

There is also only one element per xml request, so there's no need to throw any of this into a datagrid

a sample of the XML would be something like: <element><attrib1>pie</attrib1><attrib2>chocolate</attrib2><element>

so yeah, i want attrib1 and attrib2...
LVL 16
OliWarnerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

OliWarnerAuthor Commented:
at the moment my code looks a little like this:

            dim webC As New System.Net.WebClient()
            Dim orgn As String = ""
            Dim ispn As String = ""
            Dim ispd As String = ""
            Dim ispc As String = ""

        Try
            Dim remoteUrl as String = "http://www.thepcspy.com/tools/page.asp?ip=" + ip
                  Dim myDatabuffer As Byte() = webC.DownloadData(remoteUrl)
                  Dim download as String = Encoding.ASCII.GetString(myDataBuffer)

apart from the connection to the web-page cant be established to download it... its quite odd...
0
riyasjefCommented:
Why can't use xmlHTTP to do it....

See this

http://www.csharpfriends.com/Forums/ShowPost.aspx?PostID=27419

RJ
0
OliWarnerAuthor Commented:
Dim xmlHTTP As New XMLHTTP
Dim strXML As String
xmlHTTP.open("POST", strUrl)
xmlHTTP.Send(postdata)
strXML = xmlHTTP.ResponseText()
DisplayXML(ParseXML(strXML))
ProcessData = strXML

ok, but how do i requests the elemnts from the XML?
I've no exp with XML and asp.net and i'm not looking to get too bogged down in something that I could as easily build my own parser...
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

riyasjefCommented:
Here is a simple working example for you

<%@ Page language="c#"  %>
<%@ Import Namespace="System.Xml" %>
<script language="C#" runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
 Response.Write( ReadXML("http://www.csharpfriends.com/Demos/xml_XmlTextReader.xml") );
}
public string ReadXML(string UrlToXmlFile)
{
 // this string will concatenate all the xml values
 System.Text.StringBuilder sbXML = new System.Text.StringBuilder();
 XmlTextReader reader = null;
 try
 {
  // load the file from the URL
  reader = new XmlTextReader(UrlToXmlFile);
 
  object oProvinceName = reader.NameTable.Add("Province");
 
  while (reader.Read())
  {
   if (reader.NodeType == XmlNodeType.Element)
   {
    if (reader.Name.Equals(oProvinceName))
    {
     sbXML.Append(reader.ReadString()).Append("<br />");
    }      
   }
  }
  return sbXML.ToString();
 }
 catch(Exception e)
 {
  Response.Write(e.Message);
  return "";
 }
 finally
 {
 
  if (reader!=null)
   reader.Close();
 }
}
</script>
<html>
 <head>
  <title>CSharpFriends.com - ASP.NET : XmlTextReader</title>
 </head>
 <body>
  <form runat="server" ID="Form1">
  </form>
 </body>
</html>

  <?xml version="1.0" encoding="utf-8" ?>
- <Canada>
  <Province>Alberta</Province>
  <Province>British Columbia</Province>
  <Province>Manitoba</Province>
  <Province>New Brunswick</Province>
  <Province>Newfoundland and Labrador</Province>
  <Province>Northwest Territories</Province>
  <Province>Novia Scotia</Province>
  <Province>Nunavut</Province>
  <Province city="Toronto">Ontario</Province>
  <Province>Prince Edward Island</Province>
  <Province>Quebec</Province>
  <Province>Saskatchewan</Province>
  <Province>Yukon</Province>
  </Canada>

See

http://www.csharpfriends.com/articles/getArticle.aspx?articleID=309&page=2


RJ
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
OliWarnerAuthor Commented:
right , sameish error as before:

System.Net.WebException: The underlying connection was closed: Unable to connect to the remote server.

Basically I'm requesting a page which is on the same server but is dynamic and also in another language so it has to be connected through the server's output...

I'm not sure hot to get around this...
0
riyasjefCommented:
this may be problem with the proxy settings..

Is  ur client is behind a proxy ?

Check tools-->connections-->Internet options-->Lan settings
-->bypass proxy server for local addresses

Is it checked?

RJ
0
riyasjefCommented:
and give absolute path to xml file or asp file

0
OliWarnerAuthor Commented:
that wouldnt let the asp page execte would it?
and no, normal webclients to other servers work fine
0
OliWarnerAuthor Commented:
Well it would be answered but it doesnt quite work.
There's something fishy going on with asp.net requesting things from localhost... it couldnt be to do with nternal portforwarding at my host, but just incase somebody else reads this the answer is mildly incomplete if you get the same problem...

Anyway, ty for the help guys.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.