获取XML中项目的路径 [英] Get path to item in XML

查看:502
本文介绍了获取XML中项目的路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



i有一个小问题,但我无法解决这个问题..

我有一个xml文件,如果用户要求编程搜索xml中的某个值,它可以找到它并获取到这个地方的路径,在那里我们可以找到搜索值。



示例.. 。

i有这个xml文件,我想在卡路里节点找到值650,最后我想得到路径,我可以找到这个值... breakfast_menu / food / calories



Hi guys,

i have one little problem, but i can´t solve this ..
I have one xml file, and if user ask to program for search some value in xml, it can find it and get path to this place, where we can find searching value.

Example ...
i have this one xml file and i want find value 650 in calories node, and finally i want get path where i can find this value ... breakfast_menu/food/calories

<breakfast_menu>
  <food>
    <name>SKUSAM NIECO NOVE</name>
    <price>$5.95</price>
    <description>
two of our famous Belgian Waffles with plenty of real maple syrup
</description>
    <calories>650</calories>
  </food>
  <food>
    <name>Strawberry Belgian Waffles</name>
    <price>$7.95</price>
    <description>
light Belgian waffles covered with strawberries and whipped cream
</description>
    <calories>900</calories>
  </food>
  <food>
    <name>Berry-Berry Belgian Waffles</name>
    <price>$8.95</price>
    <description>
light Belgian waffles covered with an assortment of fresh berries and whipped cream
</description>
    <calories>900</calories>
  </food>
  <food>
    <name>French Toast</name>
    <price>$4.50</price>
    <description>
thick slices made from our homemade sourdough bread
</description>
    <calories>600</calories>
  </food>
</breakfast_menu>







有人可以帮我解决这个问题吗?或者更好的方式,有人持有源吗?




Could somebody help me how can i solve this please? or in better way, could somebody hold source?

推荐答案

5.95 < / price >
< 描述 >
两个着名的比利时华夫饼干,含有大量真正的枫糖浆
< / description >
< span class =code-keyword>< calories > 650 < / calories >
< span class =code-keyword>< / food >
< food >
< 名称 > Strawberry Belgian Waffles < / name >
< ; 价格 >
5.95</price> <description> two of our famous Belgian Waffles with plenty of real maple syrup </description> <calories>650</calories> </food> <food> <name>Strawberry Belgian Waffles</name> <price>


7.95 < / price >
< description >
light比利时华夫饼配草莓和生奶油
< / description >
< calories > 900 < / calories >
< / food >
< 食品 >
< 名称 > Berry-Berry比利时华夫饼< / name >
< 价格 >
7.95</price> <description> light Belgian waffles covered with strawberries and whipped cream </description> <calories>900</calories> </food> <food> <name>Berry-Berry Belgian Waffles</name> <price>


8.95 < / price >
< 描述 >
light比利时华夫饼配各种新鲜浆果和鲜奶油
< / description >
< 卡路里 > 900 < / calories >
< / food >
< food >
< 名称 > 法国吐司< / name >
< 价格 >
8.95</price> <description> light Belgian waffles covered with an assortment of fresh berries and whipped cream </description> <calories>900</calories> </food> <food> <name>French Toast</name> <price>


这篇关于获取XML中项目的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆