나는 C#에 더 신선하다. 난 XML 문서를 구문 분석하고 childnodes의 특정 노드를 계산했습니다.XML 문서의 특정 노드에 대한 자식 노드를 계산하는 방법은 무엇입니까?
예컨대 : 나는 "직원"노드를 계산 어떻게
이 XML로<Root>
<Id/>
<EmployeeList>
<Employee>
<Id/>
<EmpName/>
</Employee>
<Employee>
<Id/>
<EmpName/>
</Employee>
<Employee>
<Id/>
<EmpName/>
</Employee>
</EmployeeList>
</Root>
, ??
어떻게 구문 분석하고 C#에서 XmlDocument 클래스를 사용하여 솔루션을 얻을 수 있습니까?
XElement xElement = XElement.Parse(xml);
int count = xElement.Descendants("Employee").Count();
이렇게하면 문자열에서 XML을 가정하여 XML 파일에있는 경우,
이 정확한가요 ?? XmlElement docEle = doc.DocumentElement; XmlNodeList node = docEle.ChildNodes; (int i = 0; i
cgsabari