50,863
社区成员
发帖
与我相关
我的任务
分享
package test;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
public class Dom4JSample {
public static void main(String[] args) throws Exception{
SAXReader saxReader = new SAXReader();
Document document = saxReader.read(new File("c:/temp/test.xml"));
Element elCalibrations = document.getRootElement();
List<String> list = new ArrayList<String>();
for(Element elCalibration:elCalibrations.elements()) {
String text = elCalibration.element("Name").getText();
System.out.println("get:"+text);
list.add(text);
}
}
}
package test;
import java.io.File;
import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
public class Dom4JSample {
public static void main(String[] args) throws Exception{
SAXReader saxReader = new SAXReader();
Document document = saxReader.read(new File("c:/temp/test.xml"));
Element elCalibrations = document.getRootElement();
for(Element elCalibration:elCalibrations.elements()) {
String text = elCalibration.element("Name").getText();
System.out.println("get:"+text);
}
}
}
<Calibrations>
<Calibration>
<Value>1975</Value>
<Name>MHS Rail Front Rail Home-Bondsite</Name>
</Calibration>
<Calibration>
<Value>160</Value>
<Name>Servo Tune Z Axis Kj</Name>
</Calibration>
<Calibration>
<Value>-5</Value>
<Name>Temperature Control Z1 Offset</Name>
</Calibration>
<Calibration>
<Value>-29</Value>
<Name>Temperature Control Z2 Offset</Name>
</Calibration>
<Calibration>
<Value>-2</Value>
<Name>Temperature Control Z3 Offset</Name>
</Calibration>
<Calibration>
<Value>592</Value>
<Name>Index Gripper Sensor Semi Close Position</Name>
</Calibration>
<Calibration>
<Value>181.729</Value>
<Name>Servo Tune Y Axis Kv reverse</Name>
</Calibration>
</Calibrations>