IDE: Visual Studio 2005
Language: C# (.NET 2.0.505727)
Symptom: In debug, my page can load the xml from an external website
into an XmlDocument object. When I try to load xml from the local file,
I get no exceptions, but the XmlDocument object is empty. The xml file
is in the same folder as the aspx page with the code snippet. I'm not
sure why it's not able to load local resources. Might it have something
to do with the local webserver that VS2005 uses to debug pages? Help!!!
Here's the code:
Expand|Select|Wrap|Line Numbers
- protected void Page_Load( object sender, EventArgs e )
- {
- XmlDocument feed = new XmlDocument();
- try
- {
- string feedUrl = Page.ResolveUrl( @"~/debug/test.xml" );
- feed.Load( feedUrl );
- }
- catch( WebException feedException )
- {
- int i = 0;
- }
- catch( Exception feedException )
- {
- int i = 0;
- }
- return;
- }
Expand|Select|Wrap|Line Numbers
- <?xml version="1.0" encoding="utf-8"?>
- <rss version="2.0">
- <channel>
- <title>Sample Channel</title>
- <link>~/scenario5.aspx</link>
- <description>Channel For Scenario5 in ASP.NET RSS Toolkit
- samples.</description>
- <ttl>10</ttl>
- <name></name>
- <user></user>
- <item>
- <title>Title1</title>
- <description>Description1</description>
- <link>www.fark.com</link>
- </item>
- <item>
- <title>Title2</title>
- <description>Description2</description>
- <link>www.cnn.com</link>
- </item>
- </channel>
- </rss>
- O8