哪位高手用java解析这个xml文件 要求:1完整读出整个xml文件 2修改元素url的值 3把xml文件转换为js格式
4添加一个mod元素第3个比较重要,麻烦大虾指点,最好能有完整代码<?xmlversion='1.0'encoding='utf-8'?><ZIGUI><SYSsysna...
4添加一个mod元素
第3个比较重要,麻烦大虾指点,最好能有完整代码
<?xml version='1.0' encoding='utf-8'?>
<ZIGUI>
<SYS sysname="CREAL" desc="综合观测">
<list form="Auto" desc="自动站信息">
<mod>
<form>Auto4</form>
<desc>秭归自动站</desc>
<inframe>1</inframe>
<url>gd/moni/singleStat.jsp?Id=57358</url>
</mod>
</list>
<list>
<form>Video</form>
<desc>实景监测</desc>
<inframe>1</inframe>
<url>monitor/videoAll.jsp</url>
</list>
<list form="Moni" desc="实时监控">
<mod>
<form>Moni0</form>
<desc>自动站</desc>
<inframe>1</inframe>
<url>pms/auto/autoMonitor1.jsp</url>
</mod>
<mod>
<form>Moni1</form>
<desc>卫星云图</desc>
<inframe>1</inframe>
<url>pms/satel/satelMonitor.jsp</url>
</mod>
</list>
</SYS>
<SYS>
<list>
<form>Moni5</form>
<desc>短信</desc>
<inframe>1</inframe>
<url>monitor/msg.jsp</url>
</list>
</SYS>
<SYS>
<list>
<form>Moni6</form>
<desc>短信</desc>
<inframe>1</inframe>
<url>monitor/msg.jsp</url>
</list>
</SYS>
</ZIGUI>
以下附一段js代码
var menuArr = [
{sysname:'CREAL',desc:'综合观测',list:
[{form:'Auto',desc:'自动站信息',list:[{form:'Auto1',desc:'自动站实况',inframe:1,url:'gd/gis/auto.jsp?ShowAttr=maxScale:5,ShowStation:1,name:1,prec:1,dire:0,velo:0,temp:0,humi:0,map:Earth,lon:110.80,lat:30.9,scale:1,contourPeriod:24,showDetail:1'},
{form:'Auto2',desc:'雨量温度色斑图',inframe:1,url:'pms/collection/contour.jsp'},
{form:'Auto3',desc:'自动站统计',inframe:1,url:'auto/statistical.jsp'},
{form:'Auto4',desc:'秭归自动站',inframe:1,url:'gd/moni/singleStat.jsp?Id=57358'}]},
{form:'Radar',desc:'雷达回波',inframe:1,url:'pms/radar/radar.jsp'},
{form:'Sate',desc:'卫星云图',inframe:1,url:'pms/satel/satel.jsp'},
{form:'Hydr',desc:'水情信息',list:[{form:'HydrList',desc:'最新河道水情',inframe:1,url:'pms/collection/riverRegime.jsp'},
{form:'HydrTrend',desc:'主要站点水情趋势',inframe:1,url:'pms/collection/riverRgmCurve_new.jsp'}]},
{form:'Video',desc:'实景监测',inframe:1,url:'monitor/videoAll.jsp'}, 展开
第3个比较重要,麻烦大虾指点,最好能有完整代码
<?xml version='1.0' encoding='utf-8'?>
<ZIGUI>
<SYS sysname="CREAL" desc="综合观测">
<list form="Auto" desc="自动站信息">
<mod>
<form>Auto4</form>
<desc>秭归自动站</desc>
<inframe>1</inframe>
<url>gd/moni/singleStat.jsp?Id=57358</url>
</mod>
</list>
<list>
<form>Video</form>
<desc>实景监测</desc>
<inframe>1</inframe>
<url>monitor/videoAll.jsp</url>
</list>
<list form="Moni" desc="实时监控">
<mod>
<form>Moni0</form>
<desc>自动站</desc>
<inframe>1</inframe>
<url>pms/auto/autoMonitor1.jsp</url>
</mod>
<mod>
<form>Moni1</form>
<desc>卫星云图</desc>
<inframe>1</inframe>
<url>pms/satel/satelMonitor.jsp</url>
</mod>
</list>
</SYS>
<SYS>
<list>
<form>Moni5</form>
<desc>短信</desc>
<inframe>1</inframe>
<url>monitor/msg.jsp</url>
</list>
</SYS>
<SYS>
<list>
<form>Moni6</form>
<desc>短信</desc>
<inframe>1</inframe>
<url>monitor/msg.jsp</url>
</list>
</SYS>
</ZIGUI>
以下附一段js代码
var menuArr = [
{sysname:'CREAL',desc:'综合观测',list:
[{form:'Auto',desc:'自动站信息',list:[{form:'Auto1',desc:'自动站实况',inframe:1,url:'gd/gis/auto.jsp?ShowAttr=maxScale:5,ShowStation:1,name:1,prec:1,dire:0,velo:0,temp:0,humi:0,map:Earth,lon:110.80,lat:30.9,scale:1,contourPeriod:24,showDetail:1'},
{form:'Auto2',desc:'雨量温度色斑图',inframe:1,url:'pms/collection/contour.jsp'},
{form:'Auto3',desc:'自动站统计',inframe:1,url:'auto/statistical.jsp'},
{form:'Auto4',desc:'秭归自动站',inframe:1,url:'gd/moni/singleStat.jsp?Id=57358'}]},
{form:'Radar',desc:'雷达回波',inframe:1,url:'pms/radar/radar.jsp'},
{form:'Sate',desc:'卫星云图',inframe:1,url:'pms/satel/satel.jsp'},
{form:'Hydr',desc:'水情信息',list:[{form:'HydrList',desc:'最新河道水情',inframe:1,url:'pms/collection/riverRegime.jsp'},
{form:'HydrTrend',desc:'主要站点水情趋势',inframe:1,url:'pms/collection/riverRgmCurve_new.jsp'}]},
{form:'Video',desc:'实景监测',inframe:1,url:'monitor/videoAll.jsp'}, 展开
展开全部
你是不是要把XML数据封装成JSON对象传输啊
读取XML
public String ReadParent() {
SAXReader reader = new SAXReader();
Document doc = null;
String parent = null;
try {
InputStream in = getClass().getClassLoader().getResourceAsStream(
"Config.xml");
doc = reader.read(in);
} catch (DocumentException e1) {
e1.printStackTrace();
}
Element memory = doc.getRootElement();
Element foo = null;
for (Iterator i = memory.elementIterator("source"); i.hasNext();) {
foo = (Element) i.next();
// System.out.print("parent:" + foo.elementText("parent"));
}
parent = foo.elementText("parent");
return parent;
}
你写个bean,把数据封装成bean,然后转换成JSON对象就OK
读取XML
public String ReadParent() {
SAXReader reader = new SAXReader();
Document doc = null;
String parent = null;
try {
InputStream in = getClass().getClassLoader().getResourceAsStream(
"Config.xml");
doc = reader.read(in);
} catch (DocumentException e1) {
e1.printStackTrace();
}
Element memory = doc.getRootElement();
Element foo = null;
for (Iterator i = memory.elementIterator("source"); i.hasNext();) {
foo = (Element) i.next();
// System.out.print("parent:" + foo.elementText("parent"));
}
parent = foo.elementText("parent");
return parent;
}
你写个bean,把数据封装成bean,然后转换成JSON对象就OK
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
1:DOM DOM 是用与平台和语言无关的方式表示 XML 文档的官方 W3C 标准。DOM 是以层次结构组织的节点或信息片断的集合。这个层次结构允许开发人员2:SAX ,zfdiqw
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
建议你百度一下 jdom 读取XMl文件
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
不太明白,你把你想要得出的结果给我看看,你就说说想要解析成什么样?
追问
把这个xml文件解析成下面的js(只是一个片段)文件
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询