请教高手.XML解析问题

x_y_qing 2009-05-12 08:58:52
<?xml version="1.0" encoding="UTF-8"?>
<points>
<x>
<xTitle>3,1,1</xTitle>
<money>50</money>
<levMin>45</levMin>
<levMax>47</levMax>
<item>
<id>
<iTitle>1</iTitle>
<rate>
<rTitle>50</rTitle>
<itemType>4</itemType>
<wareType>2</wareType>
<itemId>2</itemId>
<itemNum>1</itemNum>
</rate>
</id>
<id>
<iTitle>2</iTitle>
<rate>
<rTitle>50</rTitle>
<itemType>4</itemType>
<wareType>5</wareType>
<itemId>1</itemId>
<itemNum>1</itemNum>
</rate>
</id>
<id>
<iTitle>3</iTitle>
<rate>
<rTitle>1000</rTitle>
<itemType>4</itemType>
<wareType>4</wareType>
<itemId>1</itemId>
<itemNum>1</itemNum>
</rate>
</id>
</item>
</x>


<x>
<xTitle>3,2,1</xTitle>
<money>50</money>
<levMin>50</levMin>
<levMax>52</levMax>
<item>
<id>
<iTitle>1</iTitle>
<rate>
<rTitle>500</rTitle>
<itemType>2</itemType>
<wareType>3</wareType>
<itemId>12</itemId>
<itemNum>1</itemNum>
</rate>
</id>
<id>
<iTitle>2</iTitle>
<rate>
<rTitle>2000</rTitle>
<itemType>4</itemType>
<wareType>2</wareType>
<itemId>1</itemId>
<itemNum>1</itemNum>
</rate>
</id>
</item>
</x>
</points>


我想通过<xTitle>3,1,1</xTitle>里的3,1,1取得一个X里的所有元素的值,通过<xTitle>3,2,1</xTitle>里的3,2,1取得一个X里的所有元素的值,怎么取?
我是用dom来解析的,希望高手帮帮忙...
急...在线等....


...全文
113 11 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
birdzl 2009-05-14
  • 打赏
  • 举报
回复
应该不难。跟我联系吧.我最近正好弄XSLT呢.我的QQ7287475,发给我你的XML
pagecn 2009-05-13
  • 打赏
  • 举报
回复
既然你都用Dom了,还不好处理。
首先看循环<points></points>的孩子<x></x>,变量A;
然后取出A中<xTitle></xTitle>节点值取出与你想要值比较,如果匹配,就保存A到HashMap\Vector之类;
最后HashMap中的内容即使你想要的左右<x></x>的节点
x_y_qing 2009-05-12
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 zhiyongtu 的回复:]
我在下面的帖子里有个遍历算法,稍加修改可实现你的要求:
访问xml DOM文档所有节点,并且输出节点所在的层
[/Quote]
你那个我看不明白.你的进VB吧..VB我不会...
x_y_qing 2009-05-12
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 birdzl 的回复:]
没明白什么意思,是不是根据XTITLE里的值来取啊。类似select * from table where xtitle='****'是这意思吗
[/Quote]
没错.我就是希望是这样的.
zhiyongtu 2009-05-12
  • 打赏
  • 举报
回复
我在下面的帖子里有个遍历算法,稍加修改可实现你的要求:
访问xml DOM文档所有节点,并且输出节点所在的层
birdzl 2009-05-12
  • 打赏
  • 举报
回复
没明白什么意思,是不是根据XTITLE里的值来取啊。类似select * from table where xtitle='****'是这意思吗
x_y_qing 2009-05-12
  • 打赏
  • 举报
回复
楼上的可以说下具体怎么做吗?
Dream_gril 2009-05-12
  • 打赏
  • 举报
回复
你把节点定到x那,循环比较<xtitle>里面的值
x_y_qing 2009-05-12
  • 打赏
  • 举报
回复
我有多个X节点,我想通过xTitle取得x节点里的所有内容...
x_y_qing 2009-05-12
  • 打赏
  • 举报
回复
没人会吗????
x_y_qing 2009-05-12
  • 打赏
  • 举报
回复
请教高手.....

67,549

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧