2017-06-12 72 views

回答

0

您可以通過XmlFile如讀取XML:

XmlFile file = ...; 
final XmlDocument document = file.getDocument(); 
if (document != null) { 
    final XmlTag rootTag = document.getRootTag(); 
    if (rootTag != null) { 
     final XmlTag foo = rootTag.findFirstSubTag("foo"); 
     if (foo != null) { 
      final XmlTag[] bars = foo.findSubTags("bar"); 
      if (bars.length > 1) { 
       String s = bars[1].getValue().getTrimmedText(); 
       // do something 
      } 
     } 
    } 
} 

XmlTag[] tags = root.getSubTags();得到chrildren,通過root.getName(); root.getValue().getText()

http://www.jetbrains.org/intellij/sdk/docs/reference_guide/frameworks_and_external_apis/xml_dom_api.html?search=xml

獲取標記名稱和值