안녕하세요 Evening StackOverFlowers,
Visual Studio 2010을 통해 XML로 코딩을 시작했습니다. 간단한 솔루션 인 것처럼 보이지만 아직 해결 방법이 있습니다. 나를 도망칩니다. 개체 참조가 설정되지 않았기 때문에 오류가 발생하지만 설정하지 않은 내용은 표시되지 않습니다. (여기 오류 : http://i.imgur.com/CVaxY.png)개체 참조가 개체의 인스턴스로 설정되지 않았습니다.
내 코드 숨김 : 그 말의 문제
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml;
public partial class _Default : System.Web.UI.Page
{
int intDVDID;
XmlDocument myXmlDocument = new XmlDocument();
XmlNode rootNode;
XmlNode selectedDVD;
public void Page_Load(object Src, EventArgs E)
{
intDVDID = Convert.ToInt32(Request.QueryString["id"]);
myXmlDocument.Load(Request.PhysicalApplicationPath + @"dvd.xml");
rootNode = myXmlDocument.DocumentElement;
selectedDVD = rootNode.ChildNodes[intDVDID - 1];
if (!Page.IsPostBack)
{
rootNode.RemoveChild(selectedDVD);
myXmlDocument.Save(Request.PhysicalApplicationPath + @"dvd.xml");
lblMessage.Text = "You have successfully deleted the DVD";
}
}
}
이다 : 나는 모든 당겨 할거야이를 읽어 알고
int intDVDID = new intDVDID
당신의 나의 미경험에 머리카락을 풀고 이것을 해결하는 방법을 이해하지 못하는데, 나는 당신의 시간과 당신의 인내심을보고 고맙게 생각합니다.
안부, 로라 :
편집 : 가 여기 내 XML : 그것은 null로 할 수 있습니다 귀하의 selectedDVD처럼 찾고
<?xml version="1.0" encoding="utf-8" ?>
<!-- This XML document describes a DVD library -->
<library>
<DVD id="1">
<title>Breakfast at Tiffany's</title>
<format>Movie</format>
<genre>Classic</genre>
</DVD>
<DVD id="2">
<title>Contact</title>
<format>Movie</format>
<genre>Science fiction</genre>
</DVD>
<DVD id="3">
<title>Little Britain</title>
<format>TV Series</format>
<genre>Comedy</genre>
</DVD>
</library>
'dvd.xml '은 어떻게 생겼습니까? – climbage
XML을 편집하도록 편집되었습니다. 질문 클라이 빙에 감사드립니다! –
이 오류가 발생하면'id'의 값은 무엇입니까? – climbage