검색 할 수 있습니다 :구문 분석 XML 값
<?xml version="1.0"?>
<Patients xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Person xmlns="http://ehr.org/VM/" NationalCode="1234" LastName="Morgan" FirstName="Alen">
</Person>
</Patients>
그리고 난 다음 코드를 사용하여 환자와 생일 세부 사항의 이름을 읽을려고을하지만, 몇 가지 이유 xml.SelectNodes ("/ Patients/Person")가 null이면 XML에서 값을 어떻게 읽을 수 있습니까?
XmlDocument xml = new XmlDocument();
xml.LoadXml(myXmlString);
XmlNodeList xnList = xml.SelectNodes("/Patients/Person");
foreach (XmlNode xn in xnList)
{
string firstName = xn["FirstName"].InnerText;
string lastName = xn["LastName"].InnerText;
}
는 Person 요소에 아마 네임 스페이스 :
여기 작업 코드입니다. – Amy
[C#에서 기본 네임 스페이스로 Xpath 사용하기] (https://stackoverflow.com/q/585812/3744182)를보십시오. 사실 나는 이것이 중복 된 것이라고 생각합니다. – dbc