<?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>PHPMan--Live and learn &#187; DOM</title>
	<atom:link href="http://www.phpman.com.cn/archives/tag/dom/feed" rel="self" type="application/rss+xml" />
	<link>http://www.phpman.com.cn</link>
	<description>不积跬步,无以至千里;不积小流,无以成江海</description>
	<lastBuildDate>Wed, 28 Jul 2010 02:39:54 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>该死的DOMDocument!</title>
		<link>http://www.phpman.com.cn/archives/275</link>
		<comments>http://www.phpman.com.cn/archives/275#comments</comments>
		<pubDate>Thu, 24 Sep 2009 06:37:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[DOM]]></category>

		<guid isPermaLink="false">http://www.phpman.com.cn/?p=275</guid>
		<description><![CDATA[PHP处理XML类文档主要有两个模块，一般简单点用SimpleXML,不过他只能作遍历、取值、取属性等操作，而不能进行删除修改节点的操作。使用libxml的DOMDocument功能比较强大，不过也比较麻烦。今天就遇见一问题，折腾很久～
有XML格式如下:

&#60;foo xmlns=&#34;test&#34;&#62;
&#60;bar attr='a'&#62;&#60;/bar&#62;
&#60;bar attr='b'&#62;&#60;/bar&#62;
&#60;bar attr='c'&#62;&#60;/bar&#62;
&#60;/foo&#62;

开始尝试解析

&#60;?php
    $dom = new DOMDocument;
    $dom-&#62;loadXML&#40;$xmls&#41;;//xmls变量为以上XML的字符串内容
    $messages = $dom-&#62;getElementsByTagName&#40;'bar'&#41;;
    foreach&#40;$messages as $k=&#62;$message&#41;&#123;
        if&#40;!is_object&#40;$message&#41; &#124;&#124; &#40;$message-&#62;getAttribute&#40;'attr'&#41; == 'a'&#41;&#41;&#123;
            continue;//属性attr 为a的保留   [...]]]></description>
		<wfw:commentRss>http://www.phpman.com.cn/archives/275/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
