0
어떻게 다음 XML 파일을 구문 분석 할 수 있습니까? 간단한 XML 파싱 throw 객체 참조 오류
<Website.com xmlns="">
<Matc>
<Id>1</Id>
<Date>2013-11-27T18:00:00+01:00</Date>
<Home>Moscow</Home>
</Matc>
<Matc>
<Id>2</Id>
</Matc>
</Website.com>
나는 다음 코드를 시도하지만
[Date]
및
Home
이후
Object reference not set to an instance of an object
오류가 XML 파일의 두 번째 부분에서 누락되었습니다 발생합니다.
Dim ns As XNamespace = ""
Dim matcFromXml = From m In xDoc.Descendants("Matc") Select New With { _
.Id = IIf(m.Element(ns + "Id") Is Nothing, 0, m.Descendants(ns + "Id").FirstOrDefault().Value), _
.[Date] = IIf(m.Element(ns + "Date") Is Nothing, DateTime.Now, UtcToDateTime(m.Descendants(ns + "Date").FirstOrDefault().Value)), _
.Home = IIf(m.Element(ns + "Home") Is Nothing, "", m.Descendants(ns + "Home").FirstOrDefault().Value)}
어떻게 해결할 수 있습니까? 여기서 내가 뭘 잘못하고 있니?