0
<?xml version="1.0" encoding="UTF-8"?>
<locations>
<location id="83">
<location_name>name</location_name>
<company_name>company a</company_name>
<machines>
<machine id="12">A</machine>
<machine id="312">B</machine>
</machines>
</location>
<location id="85">
<location_name>name</location_name>
<company_name>company c</company_name>
<machines>
<machine id="21">A</machine>
<machine id="45">B</machine>
</machines>
</location>
</locations>
나는 XOM을 사용하고 있으며 모든 위치 이름을 얻으려고하고 있지만 어떻게해야할지 모르겠다.XOM을 사용하는 어린이의 수당 받기
Element root = doc.getRootElement();
int i = 1;
Element child = (Element) root.getChild(i);
while(child != null)
{
System.out.println(child.getFirstChildElement("location_name").getValue());
child = (Element) root.getChild(i++);
}
하지만이 기능은 작동하지 않으며 첫 번째 이름 만 표시하고 두 번째 루프에서는 오류를 표시합니다.
그리고 두 번째 질문 : 무엇 getChildCount()
카운트 ??
실마리를주십시오, 무엇이 오류입니까? –
스택 트레이스를 보여 주시고, 진단하기가 아주 힘듭니다. –