解析XML字符串

    xiaoxiao2024-03-11  126

    怎么解析一个xml字符串?我不是第一次看到有人问这个问题了..汗

    1.使用StringReader

     

     Document doc  =  builder.parse(   new  java.io.StringReader(str)); 

    2.使用DocumentHelper.parseText()

     String text  =   " <person> <name>James</name> </person> " ;  Document document  =  DocumentHelper.parseText(text); 

    3.最苯的方法:

     

     Document doc   =   builder.parse(   new    ByteArrayInputStream(str.getBytes()));  文章转自庄周梦蝶  ,原文发布5.16 相关资源:敏捷开发V1.0.pptx
    最新回复(0)