Peter Chan
asked on
Unable to open it
Hi,
Any advice to the error I got below to this line?
105 XmlTextWriter textwrt = new XmlTextWriter("C:\\inetpub \\common.x ml", null);
Server Error in '/Login' Application.
-------------------------- ---------- ---------- ---------- ---------- ---------- ----
Access to the path 'C:\inetpub\common.xml' is denied.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.UnauthorizedAccessE xception: Access to the path 'C:\inetpub\common.xml' is denied.
ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.
To grant ASP.NET access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.
Source Error:
Line 103: Userid.InnerText = "Unable to check against the database: ";
Line 104: Userid.InnerText += ex.Message;
Line 105: }
Line 106: finally
Line 107: {
Source File: C:\dev_proj_old\Visual Studio 2008\Projects\Login\Login\ Default.as px.cs Line: 105
Stack Trace:
[UnauthorizedAccessExcepti on: Access to the path 'C:\inetpub\common.xml' is denied.]
System.IO.__Error.WinIOErr or(Int32 errorCode, String maybeFullPath) +10550419
System.IO.FileStream.Init( String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy) +2580
System.IO.FileStream..ctor (String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy) +138
System.IO.FileStream..ctor (String path, FileMode mode, FileAccess access, FileShare share) +89
System.Xml.XmlTextWriter.. ctor(Strin g filename, Encoding encoding) +63
Edit_User._Default.LoginBu tton_Click (Object sender, EventArgs e) in C:\dev_proj_old\Visual Studio 2008\Projects\Login\Login\ Default.as px.cs:105
System.Web.UI.WebControls. Button.OnC lick(Event Args e) +115
System.Web.UI.WebControls. Button.Rai sePostBack Event(Stri ng eventArgument) +140
System.Web.UI.Page.RaisePo stBackEven t(IPostBac kEventHand ler sourceControl, String eventArgument) +29
System.Web.UI.Page.Process RequestMai n(Boolean includeStagesBeforeAsyncPo int, Boolean includeStagesAfterAsyncPoi nt) +2981
-------------------------- ---------- ---------- ---------- ---------- ---------- ----
Version Information: Microsoft .NET Framework Version:2.0.50727.5456; ASP.NET Version:2.0.50727.5456
Any advice to the error I got below to this line?
105 XmlTextWriter textwrt = new XmlTextWriter("C:\\inetpub
Server Error in '/Login' Application.
--------------------------
Access to the path 'C:\inetpub\common.xml' is denied.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.UnauthorizedAccessE
ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.
To grant ASP.NET access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.
Source Error:
Line 103: Userid.InnerText = "Unable to check against the database: ";
Line 104: Userid.InnerText += ex.Message;
Line 105: }
Line 106: finally
Line 107: {
Source File: C:\dev_proj_old\Visual Studio 2008\Projects\Login\Login\
Stack Trace:
[UnauthorizedAccessExcepti
System.IO.__Error.WinIOErr
System.IO.FileStream.Init(
System.IO.FileStream..ctor
System.IO.FileStream..ctor
System.Xml.XmlTextWriter..
Edit_User._Default.LoginBu
System.Web.UI.WebControls.
System.Web.UI.WebControls.
System.Web.UI.Page.RaisePo
System.Web.UI.Page.Process
--------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.5456; ASP.NET Version:2.0.50727.5456
Do you have access to the file? Is the file already opened/used by other application?
ASKER
Yes, the login is authorized to create files in that folder. No other app is accessing it.
But the application uses windows authentication? That message says that you don't have access to the file.
Try to use IO class to check if the file exists (you will have the same error).
Try to use IO class to check if the file exists (you will have the same error).
Basically for web applications you cannot access the path outside its virtual directory.
To test this, give read rights to every one to the XML file.
To test this, give read rights to every one to the XML file.
You are definitely going outside of web/application scope, while you may be be able to configure this locally, by tweaking IIS permissions, it's unlikely you will do so in production; unless you have access to the IIS Management Console on the production server.
Alan
Alan
ASKER
Thanks all.
I now have this Xml folder in the project
http://dl.dropbox.com/u/40211031/t176.png
or please see this instead
https://skydrive.live.com/?cid=17ec75244bac022f#cid=17EC75244BAC022F&id=17EC75244BAC022F!263
I tried to open the file like this in Project A
XmlTextWriter textwrt = new XmlTextWriter("~/Xml/commo n.xml", null);
but I get this when running it within Win 08 server, after I've published the project on it
Server Error in '/Login' Application.
-------------------------- ---------- ---------- ---------- ---------- ---------- ----
Could not find a part of the path 'c:\windows\system32\inets rv\~\Xml\c ommon.xml' .
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.DirectoryNotFoun dException : Could not find a part of the path 'c:\windows\system32\inets rv\~\Xml\c ommon.xml' .
Source Error:
Line 104: Userid.InnerText += ex.Message;
Line 105: }
Line 106: finally
Line 107: {
Line 108: conn.Close();
Source File: C:\dev_proj_old\Visual Studio 2008\Projects\Login\Login\ Default.as px.cs Line: 106
Stack Trace:
[DirectoryNotFoundExceptio n: Could not find a part of the path 'c:\windows\system32\inets rv\~\Xml\c ommon.xml' .]
System.IO.__Error.WinIOErr or(Int32 errorCode, String maybeFullPath) +239
System.IO.FileStream.Init( String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy) +2580
System.IO.FileStream..ctor (String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy) +138
System.IO.FileStream..ctor (String path, FileMode mode, FileAccess access, FileShare share) +89
System.Xml.XmlTextWriter.. ctor(Strin g filename, Encoding encoding) +63
Edit_User._Default.LoginBu tton_Click (Object sender, EventArgs e) in C:\dev_proj_old\Visual Studio 2008\Projects\Login\Login\ Default.as px.cs:106
System.Web.UI.WebControls. Button.OnC lick(Event Args e) +115
System.Web.UI.WebControls. Button.Rai sePostBack Event(Stri ng eventArgument) +140
System.Web.UI.Page.RaisePo stBackEven t(IPostBac kEventHand ler sourceControl, String eventArgument) +29
System.Web.UI.Page.Process RequestMai n(Boolean includeStagesBeforeAsyncPo int, Boolean includeStagesAfterAsyncPoi nt) +2981
-------------------------- ---------- ---------- ---------- ---------- ---------- ----
Version Information: Microsoft .NET Framework Version:2.0.50727.5456; ASP.NET Version:2.0.50727.5456
I now have this Xml folder in the project
http://dl.dropbox.com/u/40211031/t176.png
or please see this instead
https://skydrive.live.com/?cid=17ec75244bac022f#cid=17EC75244BAC022F&id=17EC75244BAC022F!263
I tried to open the file like this in Project A
XmlTextWriter textwrt = new XmlTextWriter("~/Xml/commo
but I get this when running it within Win 08 server, after I've published the project on it
Server Error in '/Login' Application.
--------------------------
Could not find a part of the path 'c:\windows\system32\inets
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.DirectoryNotFoun
Source Error:
Line 104: Userid.InnerText += ex.Message;
Line 105: }
Line 106: finally
Line 107: {
Line 108: conn.Close();
Source File: C:\dev_proj_old\Visual Studio 2008\Projects\Login\Login\
Stack Trace:
[DirectoryNotFoundExceptio
System.IO.__Error.WinIOErr
System.IO.FileStream.Init(
System.IO.FileStream..ctor
System.IO.FileStream..ctor
System.Xml.XmlTextWriter..
Edit_User._Default.LoginBu
System.Web.UI.WebControls.
System.Web.UI.WebControls.
System.Web.UI.Page.RaisePo
System.Web.UI.Page.Process
--------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.5456; ASP.NET Version:2.0.50727.5456
Try using mappath to map the path to the virtual path (~\Xml\common.xml)
string FILENAME = Server.MapPath("~\Xml\comm on.xml");
XmlTextWriter textwrt = new XmlTextWriter(FILENAME);
Alan
string FILENAME = Server.MapPath("~\Xml\comm
XmlTextWriter textwrt = new XmlTextWriter(FILENAME);
Alan
ASKER
Thanks. I have these
string FILENAME = Server.MapPath(@"~\Xml\com mon.xml");
XmlTextWriter textwrt = new XmlTextWriter(FILENAME, null);
I've republished the project but I've got this when running it
Server Error in '/Login' Application.
-------------------------- ---------- ---------- ---------- ---------- ---------- ----
Could not find a part of the path 'C:\inetpub\wwwroot\Login\ Xml\common .xml'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.DirectoryNotFoun dException : Could not find a part of the path 'C:\inetpub\wwwroot\Login\ Xml\common .xml'.
Source Error:
Line 105: }
Line 106: finally
Line 107: {
Line 108: conn.Close();
Line 109: }
Source File: C:\dev_proj_old\Visual Studio 2008\Projects\Login\Login\ Default.as px.cs Line: 107
Stack Trace:
[DirectoryNotFoundExceptio n: Could not find a part of the path 'C:\inetpub\wwwroot\Login\ Xml\common .xml'.]
System.IO.__Error.WinIOErr or(Int32 errorCode, String maybeFullPath) +239
System.IO.FileStream.Init( String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy) +2580
System.IO.FileStream..ctor (String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy) +138
System.IO.FileStream..ctor (String path, FileMode mode, FileAccess access, FileShare share) +89
System.Xml.XmlTextWriter.. ctor(Strin g filename, Encoding encoding) +63
Edit_User._Default.LoginBu tton_Click (Object sender, EventArgs e) in C:\dev_proj_old\Visual Studio 2008\Projects\Login\Login\ Default.as px.cs:107
System.Web.UI.WebControls. Button.OnC lick(Event Args e) +115
System.Web.UI.WebControls. Button.Rai sePostBack Event(Stri ng eventArgument) +140
System.Web.UI.Page.RaisePo stBackEven t(IPostBac kEventHand ler sourceControl, String eventArgument) +29
System.Web.UI.Page.Process RequestMai n(Boolean includeStagesBeforeAsyncPo int, Boolean includeStagesAfterAsyncPoi nt) +2981
-------------------------- ---------- ---------- ---------- ---------- ---------- ----
Version Information: Microsoft .NET Framework Version:2.0.50727.5456; ASP.NET Version:2.0.50727.5456
string FILENAME = Server.MapPath(@"~\Xml\com
XmlTextWriter textwrt = new XmlTextWriter(FILENAME, null);
I've republished the project but I've got this when running it
Server Error in '/Login' Application.
--------------------------
Could not find a part of the path 'C:\inetpub\wwwroot\Login\
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.DirectoryNotFoun
Source Error:
Line 105: }
Line 106: finally
Line 107: {
Line 108: conn.Close();
Line 109: }
Source File: C:\dev_proj_old\Visual Studio 2008\Projects\Login\Login\
Stack Trace:
[DirectoryNotFoundExceptio
System.IO.__Error.WinIOErr
System.IO.FileStream.Init(
System.IO.FileStream..ctor
System.IO.FileStream..ctor
System.Xml.XmlTextWriter..
Edit_User._Default.LoginBu
System.Web.UI.WebControls.
System.Web.UI.WebControls.
System.Web.UI.Page.RaisePo
System.Web.UI.Page.Process
--------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.5456; ASP.NET Version:2.0.50727.5456
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yes, this does exist in the server
C:\inetpub\wwwroot\Login\X ml
I've adjusted the codes to be
...
106 string FILENAME = Server.MapPath(@"..\Xml\co mmon.xml") ;
107 ?XmlTextWriter textwrt = new XmlTextWriter(FILENAME, null);
...
but I get this
Server Error in '/Login' Application.
-------------------------- ---------- ---------- ---------- ---------- ---------- ----
Access to the path 'C:\inetpub\wwwroot\Xml\co mmon.xml' is denied.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.UnauthorizedAccessE xception: Access to the path 'C:\inetpub\wwwroot\Xml\co mmon.xml' is denied.
ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.
To grant ASP.NET access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.
Source Error:
Line 105: }
Line 106: finally
Line 107: {
Line 108: conn.Close();
Line 109: }
Source File: C:\dev_proj_old\Visual Studio 2008\Projects\Login\Login\ Default.as px.cs Line: 107
Stack Trace:
[UnauthorizedAccessExcepti on: Access to the path 'C:\inetpub\wwwroot\Xml\co mmon.xml' is denied.]
System.IO.__Error.WinIOErr or(Int32 errorCode, String maybeFullPath) +10550419
System.IO.FileStream.Init( String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy) +2580
System.IO.FileStream..ctor (String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy) +138
System.IO.FileStream..ctor (String path, FileMode mode, FileAccess access, FileShare share) +89
System.Xml.XmlTextWriter.. ctor(Strin g filename, Encoding encoding) +63
Edit_User._Default.LoginBu tton_Click (Object sender, EventArgs e) in C:\dev_proj_old\Visual Studio 2008\Projects\Login\Login\ Default.as px.cs:107
System.Web.UI.WebControls. Button.OnC lick(Event Args e) +115
System.Web.UI.WebControls. Button.Rai sePostBack Event(Stri ng eventArgument) +140
System.Web.UI.Page.RaisePo stBackEven t(IPostBac kEventHand ler sourceControl, String eventArgument) +29
System.Web.UI.Page.Process RequestMai n(Boolean includeStagesBeforeAsyncPo int, Boolean includeStagesAfterAsyncPoi nt) +2981
-------------------------- ---------- ---------- ---------- ---------- ---------- ----
Version Information: Microsoft .NET Framework Version:2.0.50727.5456; ASP.NET Version:2.0.50727.5456
when running it. Why?
Many Thanks & Best Regards,
HuaMin
C:\inetpub\wwwroot\Login\X
I've adjusted the codes to be
...
106 string FILENAME = Server.MapPath(@"..\Xml\co
107 ?XmlTextWriter textwrt = new XmlTextWriter(FILENAME, null);
...
but I get this
Server Error in '/Login' Application.
--------------------------
Access to the path 'C:\inetpub\wwwroot\Xml\co
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.UnauthorizedAccessE
ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.
To grant ASP.NET access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.
Source Error:
Line 105: }
Line 106: finally
Line 107: {
Line 108: conn.Close();
Line 109: }
Source File: C:\dev_proj_old\Visual Studio 2008\Projects\Login\Login\
Stack Trace:
[UnauthorizedAccessExcepti
System.IO.__Error.WinIOErr
System.IO.FileStream.Init(
System.IO.FileStream..ctor
System.IO.FileStream..ctor
System.Xml.XmlTextWriter..
Edit_User._Default.LoginBu
System.Web.UI.WebControls.
System.Web.UI.WebControls.
System.Web.UI.Page.RaisePo
System.Web.UI.Page.Process
--------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.5456; ASP.NET Version:2.0.50727.5456
when running it. Why?
Many Thanks & Best Regards,
HuaMin
Hi HuaMin,
That's an improvement, it's found the file:
Exception Details: System.UnauthorizedAccessE xception: Access to the path 'C:\inetpub\wwwroot\Xml\co mmon.xml' is denied.
You need to grant permissions for the actual folder, the folder named "XML".
C:\inetpub\wwwroot\Xml\
Now there's lot's of opinions about how much permission should or should not be extended, but it's your development server, on your machine, so I wouldn't worry about that too much for now.
Browse to the C:\inetpub\wwwroot\ folder using your MyComputer window.
Right click the folder 'XML' and choose properties.
In the properties dialog, on the Security tab, click the Edit button.
In the list find/select IIS_IUSRS, then check the appropriate checkboxes, then click ok.
They (IIS users) will need to be able to list folder contents, read, possibly modify too, if you intend to update this xml file; if all else fails, give them full control, it's possibly only you that uses IIS on your dev machine anyway.
Alan
That's an improvement, it's found the file:
Exception Details: System.UnauthorizedAccessE
You need to grant permissions for the actual folder, the folder named "XML".
C:\inetpub\wwwroot\Xml\
Now there's lot's of opinions about how much permission should or should not be extended, but it's your development server, on your machine, so I wouldn't worry about that too much for now.
Browse to the C:\inetpub\wwwroot\ folder using your MyComputer window.
Right click the folder 'XML' and choose properties.
In the properties dialog, on the Security tab, click the Edit button.
In the list find/select IIS_IUSRS, then check the appropriate checkboxes, then click ok.
They (IIS users) will need to be able to list folder contents, read, possibly modify too, if you intend to update this xml file; if all else fails, give them full control, it's possibly only you that uses IIS on your dev machine anyway.
Alan
ASKER
Many thanks Alan.
Hi HuaMin,
do you have a web.config in that xml folder, restricting access to authenticated users?
If not, it should work, the following is a test page ran in a different localhost site:
XmlTextReader Properties Test
===================
Name:xml
Base URI:file:///C:/inetpub/www root/site1 /xml/Items .xml
Local Name:xml
Attribute Count:2
Depth:0
Line Number:1
Node Type:XmlDeclaration
Attribute Count:version="1.0" encoding="utf-8"
Alan ";0)
do you have a web.config in that xml folder, restricting access to authenticated users?
If not, it should work, the following is a test page ran in a different localhost site:
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Xml" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
' Response.Write(Server.MapPath("../site1/xml/"))
Dim strFilePath As String = Server.MapPath("../site1/xml/Items.xml")
' Create an isntance of XmlTextReader and call Read method to read the(file)
' This works
Dim textReader As XmlTextReader = New XmlTextReader(strFilePath)
' This works too
' Dim textReader As XmlTextReader = New XmlTextReader("C:\inetpub\wwwroot\site1\xml\Items.xml")
' This won't compile
' Dim textReader As XmlTextReader = New XmlTextReader(Server.MapPath(@"..\site1\xml\Items.xml"))
textReader.Read()
' If the node has value
If textReader.HasValue Then
' Move to fist element
textReader.MoveToElement()
Response.Write("XmlTextReader Properties Test<br />")
Response.Write("===================<br />")
' Read this element's properties and display them on console
Response.Write("Name:" + textReader.Name + "<br />")
Response.Write("Base URI:" + textReader.BaseURI + "<br />")
Response.Write("Local Name:" + textReader.LocalName + "<br />")
Response.Write("Attribute Count:" + textReader.AttributeCount.ToString() + "<br />")
Response.Write("Depth:" + textReader.Depth.ToString() + "<br />")
Response.Write("Line Number:" + textReader.LineNumber.ToString() + "<br />")
Response.Write("Node Type:" + textReader.NodeType.ToString() + "<br />")
Response.Write("Attribute Count:" + textReader.Value.ToString() + "<br />")
End If
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
Returns:XmlTextReader Properties Test
===================
Name:xml
Base URI:file:///C:/inetpub/www
Local Name:xml
Attribute Count:2
Depth:0
Line Number:1
Node Type:XmlDeclaration
Attribute Count:version="1.0" encoding="utf-8"
Alan ";0)
Hi HuaMin,
Using C#, no issues too:
Using C#, no issues too:
protected void Page_Load(object sender, System.EventArgs e)
{
// Response.Write(Server.MapPath("../site1/xml/"))
string strFilePath = Server.MapPath("../site1/xml/Items.xml");
// Create an isntance of XmlTextReader and call Read method to read the(file)
// This works
System.Xml.XmlTextReader textReader = new System.Xml.XmlTextReader(strFilePath);
// This works too
// Dim textReader As XmlTextReader = New XmlTextReader("C:\inetpub\wwwroot\site1\xml\Items.xml")
// This won't compile
// Dim textReader As XmlTextReader = New XmlTextReader(Server.MapPath(@"..\site1\xml\Items.xml"))
textReader.Read();
// If the node has value
if (textReader.HasValue)
{
// Move to fist element
textReader.MoveToElement();
Response.Write("XmlTextReader Properties Test<br />");
Response.Write("===================<br />");
// Read this element's properties and display them on console
Response.Write("Name:" + textReader.Name + "<br />");
Response.Write("Base URI:" + textReader.BaseURI + "<br />");
Response.Write("Local Name:" + textReader.LocalName + "<br />");
Response.Write("Attribute Count:" + textReader.AttributeCount.ToString() + "<br />");
Response.Write("Depth:" + textReader.Depth.ToString() + "<br />");
Response.Write("Line Number:" + textReader.LineNumber.ToString() + "<br />");
Response.Write("Node Type:" + textReader.NodeType.ToString() + "<br />");
Response.Write("Attribute Count:" + textReader.Value.ToString() + "<br />");
}
}
Alan