<Point TestFlag="0" id="1" name="Conversation Set 1 Introduction" practicenaturalfemale="practice_dummy.mp3" practiceusmale="practice_dummy.mp3">
<PracticeText> </PracticeText>
<PracticeFlag> 0 </PracticeFlag>
<AudioFile gid="1" id="1" name="d002_p001.png" type="Img" />
<AudioFile gid="1" id="2" name="d001_ae_p002_01.png" type="mp3" />
</Point>
我需要获取d002_p001.png
标记中的<AudioFile>
并显示
怎么做请帮忙
答案 0 :(得分:0)
如果您使用的是java,则代码为
导入列表
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
初始化部分
String xmlFile = "audio.xml";
File xmlFileF = new File(xmlFile);
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setIgnoringElementContentWhitespace(true);
Document document = factory.newDocumentBuilder().parse(xmlFile);
检索属性名称
Element audioFileElement = (Element)document.getElementsByTagName("AudioFile").item(0);
String fileName = moduleElement.getAttribute("name");
System.out.println(fileName);