<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>我想网 &#187; XML</title>
	<atom:link href="http://www.iwanna.cn/topics/develope/xml-develope/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.iwanna.cn</link>
	<description></description>
	<lastBuildDate>Mon, 26 Dec 2011 05:46:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>PHP用正则表达式解析 XML</title>
		<link>http://www.iwanna.cn/archives/2009/07/05/1936/</link>
		<comments>http://www.iwanna.cn/archives/2009/07/05/1936/#comments</comments>
		<pubDate>Sun, 05 Jul 2009 15:06:17 +0000</pubDate>
		<dc:creator>seasun</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[RegEx]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[Original]]></category>

		<guid isPermaLink="false">http://www.iwanna.cn/?p=1936</guid>
		<description><![CDATA[&#60;?php $xml = &#8220;&#8221;; $f = fopen( &#8216;books.xml&#8217;, &#8216;r&#8217; ); while( $data = fread( $f, 4096 ) ) { $xml .= $data; } fclose( $f ); preg_match_all( &#8220;/\&#60;book\&#62;(.*?)\&#60;\/book\&#62;/s&#8221;, $xml, $bookblocks ); foreach( $bookblocks[1] as $block ) { preg_match_all( &#8220;/\&#60;author\&#62;(.*?)\&#60;\/author\&#62;/&#8221;, $block, $author ); preg_match_all( &#8220;/\&#60;title\&#62;(.*?)\&#60;\/title\&#62;/&#8221;, $block, $title ); preg_match_all( &#8220;/\&#60;publisher\&#62;(.*?)\&#60;\/publisher\&#62;/&#8221;, $block, $publisher ); echo( $title[1][0] . [...]]]></description>
			<content:encoded><![CDATA[<p>&lt;?<a href="http://www.iwanna.cn/tags/php/" class="st_tag internal_tag" rel="tag" title="标签 PHP 下的日志">php</a><br />
$<a href="http://www.iwanna.cn/tags/xml/" class="st_tag internal_tag" rel="tag" title="标签 XML 下的日志">xml</a> = &#8220;&#8221;;<br />
$f = fopen( &#8216;books.xml&#8217;, &#8216;r&#8217; );<br />
while( $data = fread( $f, 4096 ) ) { $xml .= $data; }<br />
fclose( $f );</p>
<p>preg_match_all( &#8220;/\&lt;book\&gt;(.*?)\&lt;\/book\&gt;/s&#8221;, $xml, $bookblocks );</p>
<p>foreach( $bookblocks[1] as $block ) {<br />
preg_match_all( &#8220;/\&lt;author\&gt;(.*?)\&lt;\/author\&gt;/&#8221;, $block, $author );<br />
preg_match_all( &#8220;/\&lt;title\&gt;(.*?)\&lt;\/title\&gt;/&#8221;, $block, $title );<br />
preg_match_all( &#8220;/\&lt;publisher\&gt;(.*?)\&lt;\/publisher\&gt;/&#8221;, $block, $publisher );<br />
echo( $title[1][0] . &#8221; &#8211; &#8221; . $author[1][0] . &#8221; &#8211; &#8221; . $publisher[1][0] . &#8220;\n&#8221; );<br />
}<br />
?&gt;</p>
<p>正则表达式对于小量的XML数据解析比较高效，如果是大数据量的，那么就请使用 <a href="http://www.iwanna.cn/tags/dom/" class="st_tag internal_tag" rel="tag" title="标签 DOM 下的日志">DOM</a> 库读取 XML 或 SAX 解析器读取 XML 吧！！</p>
<hr />
<p>© <a href="http://www.iwanna.cn">我想网</a> Akon 所有 , 2009. |
<a href="http://www.iwanna.cn/archives/2009/07/05/1936/">永久链接</a> |
<a href="http://www.iwanna.cn/archives/2009/07/05/1936/#comments">没有评论</a> |
提交到
<a rel="nofollow" target="_blank" href="http://www.google.com/reader/view/feed/http://www.iwanna.cn/archives/2009/07/05/1936/">Google Reader</a>
<a rel="nofollow" target="_blank" href="http://www.xianguo.com/subscribe.php?url=http://www.iwanna.cn/archives/2009/07/05/1936/">鲜果</a>
<a rel="nofollow" target="_blank" href="http://www.zhuaxia.com/add_channel.php?url=http://www.iwanna.cn/archives/2009/07/05/1936/">抓虾</a>
<hr />
<script type="text/javascript"><!--
google_ad_client = "pub-2057344547305288";
/* 336x280,iwanna feed,created 10/3/10 */
google_ad_slot = "9738886183";
google_ad_width = 336;
google_ad_height = 280;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<hr />
</p>
<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.iwanna.cn/archives/2009/07/05/1936/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>用 PHP 读取和编写 XML DOM</title>
		<link>http://www.iwanna.cn/archives/2009/07/05/1933/</link>
		<comments>http://www.iwanna.cn/archives/2009/07/05/1933/#comments</comments>
		<pubDate>Sun, 05 Jul 2009 14:59:07 +0000</pubDate>
		<dc:creator>seasun</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[DOM]]></category>

		<guid isPermaLink="false">http://www.iwanna.cn/?p=1933</guid>
		<description><![CDATA[http://www.ibm.com/developerworks/cn/opensource/os-xmldomphp/ http://www.phpe.net/manual/ref.xml.php © 我想网 Akon 所有 , 2009. &#124; 永久链接 &#124; 没有评论 &#124; 提交到 Google Reader 鲜果 抓虾 Feed enhanced by Better Feed from Ozh]]></description>
			<content:encoded><![CDATA[<p>http://www.ibm.com/developerworks/cn/opensource/os-xmldomphp/</p>
<p>http://www.phpe.net/manual/ref.<a href="http://www.iwanna.cn/tags/xml/" class="st_tag internal_tag" rel="tag" title="标签 XML 下的日志">xml</a>.<a href="http://www.iwanna.cn/tags/php/" class="st_tag internal_tag" rel="tag" title="标签 PHP 下的日志">php</a></p>
<hr />
<p>© <a href="http://www.iwanna.cn">我想网</a> Akon 所有 , 2009. |
<a href="http://www.iwanna.cn/archives/2009/07/05/1933/">永久链接</a> |
<a href="http://www.iwanna.cn/archives/2009/07/05/1933/#comments">没有评论</a> |
提交到
<a rel="nofollow" target="_blank" href="http://www.google.com/reader/view/feed/http://www.iwanna.cn/archives/2009/07/05/1933/">Google Reader</a>
<a rel="nofollow" target="_blank" href="http://www.xianguo.com/subscribe.php?url=http://www.iwanna.cn/archives/2009/07/05/1933/">鲜果</a>
<a rel="nofollow" target="_blank" href="http://www.zhuaxia.com/add_channel.php?url=http://www.iwanna.cn/archives/2009/07/05/1933/">抓虾</a>
<hr />
<script type="text/javascript"><!--
google_ad_client = "pub-2057344547305288";
/* 336x280,iwanna feed,created 10/3/10 */
google_ad_slot = "9738886183";
google_ad_width = 336;
google_ad_height = 280;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<hr />
</p>
<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.iwanna.cn/archives/2009/07/05/1933/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

