如何查询xml以获取特定节点 [英] how to query xml so as to get specific nodes

查看:73
本文介绍了如何查询xml以获取特定节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<?xml version="1.0" encoding="UTF-8" ?> 
- <!--  Generated on Sat, 17 Dec 2011 16:40:23 +0530 
  --> 
- <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
- <channel>
  <atom:link href="http://www.business-standard.com/rss/rss_icon.png" rel="self" type="application/rss+xml" /> 
- <title>
- <![CDATA[ Markets & Investing ->News Now
   
  </title>
  <link>http://www.business-standard.com/</link> 
  <description>The latest news from India's most respected business daily.</description> 
  <language>en-us</language> 
  <managingEditor>webtech@bsmail.in (Webmaster)</managingEditor> 
  <webMaster>webtech@bsmail.in (Webmaster)</webMaster> 
  <generator>PHP RSS Feed Generator</generator> 
- <image>
  <url>http://www.business-standard.com/india/images/logo_08.jpg</url> 
  <title>Business-Standard</title> 
  <link /> 
  <width>248</width> 
  <height>146</height> 
  </image>
- <item>
- <title>
- <![CDATA[ Gold snaps 5-day losing streak, gains Rs 75

   

  </title>
- <description>
- <![CDATA[ Snapping five-day losing streak, gold prices recovered Rs 75 to Rs 27,840 per 10 gram in the national capital today on buying at lower levels amid firm trend overseas.

   

  </description>
  <link>http://www.business-standard.com/india/news/gold-snaps-5-day-losing-streak-gains-rs-75/153154/on</link> 
  <pubDate>Sat, 17 Dec 2011 15:38:06 +0530</pubDate> 
  <guid isPermaLink="true">http://www.business-standard.com/india/news/gold-snaps-5-day-losing-streak-gains-rs-75/153154/on</guid> 
  </item>
- <item>
- <title>
- <![CDATA[ Weekly Report Sensex, Nifty hit 2-yr lows on growth woes

   

  </title>
- <description>
- <![CDATA[ In the week to December 16, benchmark share indices ended at their two-year lows weighed by dismal October IIP data, weakening rupee, high headline inflation and growth concerns.

   

  </description>
  <link>http://www.business-standard.com/india/news/weekly-report-sensex-nifty-hit-2-yr-lowsgrowth-woes/153144/on</link> 
  <pubDate>Sat, 17 Dec 2011 09:50:14 +0530</pubDate> 
  <guid isPermaLink="true">http://www.business-standard.com/india/news/weekly-report-sensex-nifty-hit-2-yr-lowsgrowth-woes/153144/on</guid> 
  </item>
- <item>
- <title>
- <![CDATA[ Growth sectors lead Wall Street higher

   

  </title>
- <description>
- <![CDATA[ US stocks rose on Friday with growth-related shares leading the way as investors focused on a brighter US economic outlook.

   

  </description>
  <link>http://www.business-standard.com/india/news/growth-sectors-lead-wall-street-higher/153139/on</link> 
  <pubDate>Fri, 16 Dec 2011 21:24:36 +0530</pubDate> 
  <guid isPermaLink="true">http://www.business-standard.com/india/news/growth-sectors-lead-wall-street-higher/153139/on</guid> 
  </item>
- <item>
- <title>
- <![CDATA[ Sebi working on exit policy for bourses

   

  </title>
- <description>
- <![CDATA[ Market regulator the Securities and Exchange Board of India (Sebi) is working on a number of new regulations for the stock exchanges, including a business-exit policy and moving the Investor Protection Funds of all bourses to a single agency.

   

  </description>
  <link>http://www.business-standard.com/india/news/sebi-workingexit-policy-for-bourses/153135/on</link> 
  <pubDate>Fri, 16 Dec 2011 20:52:43 +0530</pubDate> 
  <guid isPermaLink="true">http://www.business-standard.com/india/news/sebi-workingexit-policy-for-bourses/153135/on</guid> 
  </item>


如何查询它以获取所有项目"节点.
请我尝试此操作,但找不到确切答案,造成很多困惑.


how to query this so as to get all "item" nodes.
please i tried this but could not find exact answer,confused a lot

推荐答案

魔术词是一个五个字母的词,称为XPath.
1. Google
2.仔细阅读
3.试用您会发现的大量示例
4.最后,利用它从XML中提取所有项目标签.
The magic word is a five letter word called XPath.
1. Google it
2. Read up on it
3. Try out the abundant examples you''ll find
4. Finally utilize it to extract all the item tags from your XML.


这篇关于如何查询xml以获取特定节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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