<career code="17-1011.00">
<code>17-1011.00</code>
<title>Architects</title>
<tags bright_outlook="false" green="true" apprenticeship="false" />
<also_called>
<title>Architect</title>
<title>Project Architect</title>
<title>Project Manager</title>
<title>Architectural Project Manager</title>
</also_called>
<what_they_do>Plan and design structures, such as private residences, office buildings, theaters, factories, and other structural property.</what_they_do>
<on_the_job>
<task>Consult with clients to determine functional or spatial requirements of structures.</task>
<task>Prepare scale drawings.</task>
<task>Plan layout of project.</task>
</on_the_job>
</career>
이 XML을 ONet에서 반환했으며 사용할 정보를 구문 분석하고 싶습니다. 다음은 Onet XML 인 'input'을 사용하여 아래 태그의 내부 텍스트를 분석하고 구문 분석하도록 작성한 코드입니다.내부 XML 태그 구문 분석 C#
XmlDocument inputXML = new XmlDocument();
inputXML.LoadXml(input);
XmlElement root = inputXML.DocumentElement;
XmlNodeList titleList = root.GetElementsByTagName("also_called");
for (int i = 0; i < titleList.Count; i++)
{
Console.WriteLine(titleList[i].InnerText);
}
크기가 4 인 NodeList가 필요합니다. 그러나 결과를 인쇄 할 때 결과는 1 크기입니다. "ArchitectProject ArchitectProject ManagerArchitectural Project Manager"
XMLNodeList titleList를 잘못 구성 했습니까? XML 트리를 더 자세히 트래버스하고 처리하여 'also_called'아래에 'title'태그의 내부 값을 가져올 수 있습니까?
XDocument 제안을위한 +1 –