如何从XML嵌套结构中生成树或者图? 最好有相关代码,生成Eclipse的图形即可,谢谢!
简单的Sample代码如下:
  
<?xml version="1.0" encoding="UTF-8" ?>
<profile timeoffset="-1531115380">
<threads>
 <thread id="008b1620" name="Unnamed Thread (main?)">
 <calls>
  <method name="test.Main.main" signature="([Ljava/lang/String;)V">
  <method name="test.Test.&lt;init&gt;" signature="()V">
   <time selfduration="31" />
  </method>
  <method name="test.Test.loop" signature="()V">
  <method name="test.Test.call" signature="(I)V">
   <time selfduration="2862" />
  </method>
  <method name="test.Test.call" signature="(I)V">
   <time selfduration="1696" />
  </method>
  <method name="test.Test.call" signature="(I)V">
   <time selfduration="1688" />
  </method>
  <method name="test.Test.call" signature="(I)V">
   <time selfduration="1706" />
  </method>
  <method name="test.Test.call" signature="(I)V">
   <time selfduration="1691" />
  </method>
  <method name="test.Test.call" signature="(I)V">
   <time selfduration="1686" />
  </method>
  <method name="test.Test.call" signature="(I)V">
   <time selfduration="1685" />
  </method>
  <method name="test.Test.call" signature="(I)V">
   <time selfduration="2599" />
  </method>
  <method name="test.Test.call" signature="(I)V">
   <time selfduration="2673" />
  </method>
  <method name="test.Test.call" signature="(I)V">
   <time selfduration="1686" />
  </method>
   <time selfduration="20" />
  </method>
  <method name="test.Test.recursive" signature="(I)V">
  <method name="test.Test.recursive" signature="(I)V">
  <method name="test.Test.recursive" signature="(I)V">
  <method name="test.Test.recursive" signature="(I)V">
  <method name="test.Test.recursive" signature="(I)V">
  <method name="test.Test.recursive" signature="(I)V">
   <time selfduration="1711" />
  </method>
   <time selfduration="1735" />
  </method>
   <time selfduration="1744" />
  </method>
   <time selfduration="1737" />
  </method>
   <time selfduration="1689" />
  </method>
   <time selfduration="1698" />
  </method>
   <time selfduration="18" />
  </method>
 </calls>
 </thread>
 <thread id="008b2df0" name="Signal Dispatcher">
 <calls>
 </calls>
 </thread>
 <thread id="008bca30" name="Unnamed Thread (main?)">
 <calls>
 </calls>
 </thread>
</threads>
</profile>
 

解决方案 »

  1.   

    Eclipse的图形是什么?
    首先得找个树或图的代码实现、必须有定位、加入节点方法。
    然后读xml向这个结构里加节点。dom4j最好用、其次jdom
    不知楼主是不是问这个
      

  2.   

    可以看看wst 的webservice的组件,其中有解析xml生成emf/gef
      

  3.   

    就是根据某一个XML文件,在Eclipse作为插件的形式,图形化显示层次关系,不知道大家有没有好办法?谢谢啦