这是从 xml 中删除所有命名空间的方法。但这对我不起作用。因为有时我会收到损坏的 xml 提要。例如:
<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress.com" -->
<rss version="2.0"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/">
<channel>
<title>sabri ?lker - WordPress.com Search</title>
<link>http://tr.search.wordpress.com/?q=sabri+%C3%BClker&page=2&t=comment&s=date</link>
<description>sabri ?lker - WordPress.com Search</description>
<pubDate>Fri, 04 Jan 2013 08:58:41 +0000</pubDate>
<language>tr</language>
<image><url>http://s.wordpress.com/i/buttonw-com.png</url><width>224</width><height>58</height><title>WordPress.com</title><link>http://wordpress.com/</link></image>
<generator>http://search.wordpress.com/</generator>
<atom:link rel="self" type="application/rss+xml" href="http://tr.search.wordpress.com/?q=sabri+%C3%BClker&page=2&t=comment&s=date&f=feed" />
<atom:link rel="search" type="application/opensearchdescription+xml" href="http://en.search.wordpress.com/opensearch.xml" title="WordPress.com" />
<opensearch:totalResults>10</opensearch:totalResults><opensearch:startIndex>11</opensearch:startIndex><opensearch:itemsPerPage>10</opensearch:itemsPerPage><opensearch:Query role="request" searchTerms="sabri ?lker startPage=\"2" /></channel>
</rss>
我的例外是“名称不能以 '2' 字符开头,十六进制值 0x32。第 17 行,位置 227。” 到结果。那么我应该怎么做才能解决这个问题。