< os owner =“microsoft”version =“windows xp”link =“microsft.com/windows98”information =“microsoft.com/windows98/more_info”/>
< os owner =“microsoft”version =“windows 2000”link =“microsft.com/windows2000”information =“microsoft.com/windows2000/more_info”/>
< os owner =“microsoft”version =“windows windows 7”link =“microsft.com/windows7”information =“microsoft.com/windows7/more_info”/>
< os owner =“Fedora”version =“Fedora core 4”link =“fedora.com/4”information =“fedora.com/4/more_info”/>
< os owner =“Fedora”version =“Fedora core 5”link =“fedora.com/5”information =“fedora.com/6/more_info”/>
< os owner =“Fedora”version =“Fedora core 6”link =“fedora.com/6”information =“fedora.com/6/more_info”/>
< os owner =“Fedora”version =“Fedora core 7”link =“fedora.com/7”information =“fedora.com/7/more_info”/>
< os owner =“Fedora”version =“Fedora core 8”link =“fedora.com/8”information =“fedora.com/8/more_info”/>
< os owner =“Fedora”version =“Fedora core 9”link =“fedora.com/9”information =“fedora.com/9/more_info”/>
< os owner =“Fedora”version =“Fedora core 10”link =“fedora.com/10”information =“fedora.com/10/more_info”/>
< os owner =“Redhat”version =“Redhat 4”link =“redhat.com/4”information =“redhat.com/4/more_info”/>
< os owner =“Redhat”version =“Redhat 5”link =“redhat.com/5”information =“redhat.com/5/more_info”/>
< os owner =“Redhat”version =“Redhat 6”link =“redhat.com/6”information =“redhat.com/6/more_info”/>
< os owner =“Redhat”version =“Redhat 7”link =“redhat.com/7”information =“redhat.com/7/more_info”/>
< os owner =“Redhat”version =“Redhat 8”link =“redhat.com/8”information =“redhat.com/8/more_info”/>
< os owner =“Redhat”version =“Redhat 9”link =“redhat.com/9”information =“redhat.com/9/more_info”/>
< os owner =“Redhat”version =“Redhat 2010”link =“redhat.com/2010”information =“redhat.com/2010 / more_info”/>
我已经将所有者名称作为microsoft,现在我想显示特定所有者的版本,链接和信息
如何通过“微软”并仅显示微软的结果
如何在Javascript中完成此任务 请帮忙
提前致谢
戴夫
答案 0 :(得分:0)
如果您的信息是XML格式,我猜您可以使用类似
的xpath//os[@owner="microsoft"]/
问题是您必须使用库或其他东西在JS(http://www.w3schools.com/Xml/xml_parser.asp)中执行xpath查询...我认为MooTools可以将一个xml加载到DOM然后使用选择器,如
$$('os[owner="microsoft"]')
我不太确定那个......而我最后的猜测是你可以使用常规表达来提取行
答案 1 :(得分:0)
您可以尝试将您的xml数据转换为DOM,例如关于http://outwestmedia.com/jquery-plugins/xmldom/ jQuery插件,并使用不同的jQuery选择器(请参阅http://api.jquery.com/category/selectors/)来选择或仅查找XML的元素你需要。
另一种方法是将您的XML数据转换为可以在互联网上找到的解决方案的JSON数据(例如,请参阅http://www.thomasfrank.se/xml_to_json.html)。 JSON数据可以转换为JSON.parse
的JavaScript对象。然后,您可以在没有或使用jQuery的情况下轻松遍历javascript对象。