首页javaxpathJava HTML/XML - 如何搜索XPath

Java HTML/XML - 如何搜索XPath

我们想知道如何搜索XPath。
 

import java.io.FileReader;

import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathFactory;

import org.xml.sax.InputSource;

public class Main {

    public static void main(String[] args) throws Exception {
        XPathFactory factory = XPathFactory.newInstance();
        XPath xPath = factory.newXPath();

        String result = xPath.evaluate("/schedule/@name", new InputSource(
                new FileReader("tds.xml")));
        System.out.println(result);
    }
}