Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用jquery仅从xml获取所选父级的子级?_Jquery_Xml_Jquery Mobile - Fatal编程技术网

如何使用jquery仅从xml获取所选父级的子级?

如何使用jquery仅从xml获取所选父级的子级?,jquery,xml,jquery-mobile,Jquery,Xml,Jquery Mobile,我正在学习jquery,并尝试使用jquery从xml获取加载数据。我在listview中获取父标记,当我单击特定父标记时,它将获取所有父标记的所有子标记 XML文件: <?xml version="1.0" encoding="UTF-8" standalone="no"?> <page count="56" name="ebook"> <sections> <section count="7" name="Seduce Your Part

我正在学习jquery,并尝试使用jquery从xml获取加载数据。我在listview中获取父标记,当我单击特定父标记时,它将获取所有父标记的所有子标记

XML文件:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<page count="56" name="ebook">
  <sections>
    <section count="7" name="Seduce Your Partner" order="1">
      <content file="93828.txt" order="1">Balmy with rich perfumes</content>
      <content file="93829.txt" order="2">Wear a fine dress</content>
      <content file="93830.txt" order="3">Welcome to Love Abode</content>
      <content file="93831.txt" order="4">Rekindle your love</content>
      <content file="93832.txt" order="5">Flower a love messanger</content>
      <content file="93833.txt" order="6">Perfumes and Aromas</content>
      <content file="93834.txt" order="7">Gain a women&amp;apos;s heart</content>
    </section>
    <section count="6" name="The Touch of Love" order="2">
      <content file="93835.txt" order="8">A Love Message</content>
      <content file="93836.txt" order="9">An awakening kiss</content>
      <content file="93837.txt" order="10">Heading South with Confidence</content>
      <content file="93838.txt" order="11">Caressing</content>
      <content file="93839.txt" order="12">Stroking</content>
      <content file="93840.txt" order="13">Blows &amp;amp; Cries</content>
    </section>
    <section count="8" name="Beyond Touch" order="3">
      <content file="93841.txt" order="14">Watch, Listen &amp;amp; Experiment</content>
      <content file="93842.txt" order="15">Blindfolded</content>
      <content file="93843.txt" order="16">Embrace of Jaghana</content>
      <content file="93844.txt" order="17">Piercing Embrace</content>
      <content file="93845.txt" order="18">Twining of a Creeper</content>
      <content file="93846.txt" order="19">Line of Jewels</content>
      <content file="93847.txt" order="20">Token of Remembrance</content>
      <content file="93848.txt" order="21">Oils and Lotions</content>
    </section>
  </sections>
</page>

芳香馥郁
穿一件漂亮的衣服
欢迎来到爱之家
重新点燃你的爱
花是爱是愤怒
香味
获得一个妇女和儿童基金会;载脂蛋白;心
爱的信息
觉醒的吻
满怀信心地往南走
爱抚
抚摸
打击及;amp;哭
看、听、看;amp;实验
蒙着眼睛
加纳的拥抱
锐利的拥抱
藤蔓缠绕
珠宝系列
纪念物
油和乳液
这是我的xml文件。我正在获取属性为“name”的所有父标记,但问题是当我单击列表中的特定父标记时,它将获取所有父标记的所有子标记

请参见此处的问题:

有谁能帮我找到解决办法,让我只得到那个父母的孩子

提前谢谢


谢谢Omar..这就是我正在寻找的,但我想知道更多的事情“如何在子标记中打开文件”。例如,在上面的xml文件中,“我们为每个家长都有一个如下的子标记

<content file="93828.txt" order="1">Balmy with rich perfumes</content>
      <content file="93829.txt" order="2">Wear a fine dress</content>
芳香浓郁
穿一件漂亮的衣服
当我点击儿童标签时,例如:香薰香水“93828.txt”文件必须打开。当我点击儿童标签时,如何打开此文件

例如“93828.txt”文件:用于“诱惑你的伴侣”中的“芳香浓郁的香水”


香薰香薰香薰香薰香薰香薰香薰香薰香薰香薰香薰香薰香薰香薰香薰香薰香薰香薰香薰香薰香薰香薰香薰香薰香薰香薰香薰香薰香薰香薰香薰香薰香薰香薰香薰香薰香薰香薰香薰香薰享受。理想情况下,你的床应该舒适诱人,周围有足够的空间让你感到放松。你应该能够精力充沛地移动,而不会发出烦人的吱吱声或砰砰声。无论你的品味是红色天鹅绒还是白色亚麻布,都要努力营造一种愉悦、放松和娱乐的美学。你需要的物品方便取用的物品包括:

*饮用水和纸巾

*薄荷糖或八角糖

*润滑剂和避孕套

*颈枕(用于臀部下方)爱情玩具和鸵鸟羽毛<香水>香薰油,蜡烛、火柴、蜡烛、火柴>请确保你的卧室闻起来很香,柔和地点亮,不要忘记合适的音乐。考虑把蜡烛放在墙上,把你的爱的影子投射到墙上,或者镜子里你可以瞥见你自己。美味的水果,情诗,甚至棋盘游戏。

93835.txt:用于“爱的触摸”中的“爱的信息”


当一个女孩用舌头触摸她情人的嘴唇,闭上眼睛,把手放在她情人的嘴唇上时,这就是所谓的触摸吻。每天都有机会接受或传递触摸吻,这是最温柔、最激动人心的吻。你可以从这里开始三个基本的吻,直吻、弯吻和转吻。

直吻和听起来一样,你们两个面对面。弯曲是指头部向一侧倾斜,翻转是指一个人拿着另一个人的下巴和头部,仰起脸亲吻。如果你紧急地接吻,这被称为压吻。

强烈的迷恋会让爱人分心,导致爱人在镜子或水中的倒影,或墙上的影子。当这一切结束时,这叫做一个表示意图的吻,只有那些因爱而晕眩的人才会这样做。如果他们在心上人面前轻吻一个孩子、一幅画或一个小雕像,让对方知道这个吻的真正目的是谁,这就叫做转移吻。这是一种偷偷摸摸的方式,在混血儿中传递爱的信息。在电影或派对上,你可以通过亲吻你的指尖并触摸到你爱人的手指或脚趾来表达你的爱。

请参阅更新的Html文件和Js的链接:


提前感谢。

您需要根据
部分
id查找
内容。检查下面的示例和代码

创建
部分的列表

var xml = 'xml code here';

$(xml).find('section').each(function () {
 var section = $(this).attr("name");
 var order = $(this).attr("order");
 $("#section_list").append('<li><a href="#chapter" id="' + order + '">' + section + '  </a> </li>');
 $("#section_list").listview('refresh');
});

最新答案 参考您的评论和更新的问题,以下是代码。但是首先,您需要将
file.txt
添加到
链接中,如下所示

var file = $(this).attr('file');
$('#content_list').append('<li><a href="#" file="' + file + '">' + content + ' </a></li>');
我给了这个页面一个id
#words
把它改成适合你的


如果您有任何问题,请告诉我。

您需要根据
部分
id查找
内容。检查下面的示例和代码

创建
部分的列表

var xml = 'xml code here';

$(xml).find('section').each(function () {
 var section = $(this).attr("name");
 var order = $(this).attr("order");
 $("#section_list").append('<li><a href="#chapter" id="' + order + '">' + section + '  </a> </li>');
 $("#section_list").listview('refresh');
});

最新答案 参考您的评论和更新的问题,以下是代码。但是首先,您需要将
file.txt
添加到
链接中,如下所示

var file = $(this).attr('file');
$('#content_list').append('<li><a href="#" file="' + file + '">' + content + ' </a></li>');
我给了这个页面一个id
#words
把它改成适合你的


如果您有任何问题,请告诉我。

谢谢Omar。这就是我正在查找的内容,我想知道如何在child标记中打开文件。你能看到上面的我更新了我的数据。提前谢谢Hanks Omar..这就是我正在寻找的,我想知道如何在子标签中打开文件。你能看到上面的一个吗?我更新了我的数据。提前感谢检查更新的答案。非常感谢Omar..它工作得很好..我尝试过更新动态更改标题的代码,它工作得很好,但它有一个问题,比如更改h
var file = $(this).attr('file');
$('#content_list').append('<li><a href="#" file="' + file + '">' + content + ' </a></li>');
$(document).on('click', '#content_list li a', function () {
 var file = $(this).attr('file');
 if($('[data-role=page]#words').length === 0) {
  $($.mobile.pageContainer).append('<div data-role="page" id="words" data-add-back-btn="true"><div data-role="header"><h1>Words</h1></div><div data-role="content"></div></div>');
  $('[data-role=page]#words [data-role=content]').load('path/'+file);
  $.mobile.changePage('#words');
 }
 else {
  $('[data-role=page]#words [data-role=content]').empty();
  $('[data-role=page]#words [data-role=content]').load('path/'+file);
  $.mobile.changePage('#words');
 }
});