GeoRSS <description> is not properly parsed if multiple children. r=crschmidt (closes #2780)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@11574 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Frédéric Junod
2011-02-28 08:10:10 +00:00
parent 8beb04d2ca
commit f7d58dc36c
2 changed files with 10 additions and 1 deletions
+1 -1
View File
@@ -253,7 +253,7 @@ OpenLayers.Format.GeoRSS = OpenLayers.Class(OpenLayers.Format.XML, {
var eles = this.getElementsByTagNameNS(node, nsuri, name); var eles = this.getElementsByTagNameNS(node, nsuri, name);
if(eles && eles[0] && eles[0].firstChild if(eles && eles[0] && eles[0].firstChild
&& eles[0].firstChild.nodeValue) { && eles[0].firstChild.nodeValue) {
value = eles[0].firstChild.nodeValue; value = OpenLayers.Format.XML.prototype.getChildValue(eles[0]);
} else { } else {
value = (def == undefined) ? "" : def; value = (def == undefined) ? "" : def;
} }
+9
View File
@@ -74,6 +74,15 @@
} }
} }
function test_leading_space(t) {
t.plan(2);
var parser = new OpenLayers.Format.GeoRSS();
var items = parser.read('<rss version="2.0" xmlns:georss="http://www.georss.org/georss"><item><description> <![CDATA[foo]]></description></item></rss>');
t.eq(items.length, 1, "item created");
t.eq(items[0].attributes.description, " foo", "description value is ok");
}
var shell_start = '<feed xmlns="http://www.w3.org/2005/Atom" \n xmlns:georss="http://www.georss.org/georss">\n <title>scribble</title>\n <id>http://featureserver.org/featureserver.cgi/scribble?format=atom</id>\n <author><name>FeatureServer</name></author>\n'; var shell_start = '<feed xmlns="http://www.w3.org/2005/Atom" \n xmlns:georss="http://www.georss.org/georss">\n <title>scribble</title>\n <id>http://featureserver.org/featureserver.cgi/scribble?format=atom</id>\n <author><name>FeatureServer</name></author>\n';
var shell_end = '</feed>'; var shell_end = '</feed>';
var input = ['<entry><id>http://featureserver.org/featureserver.cgi/scribble/562.atom</id><link href="http://featureserver.org/featureserver.cgi/scribble/562.atom"/><title>Feature 2</title><content type="html">&lt;b&gt;strokeColor&lt;/b&gt;: red&lt;br /&gt;&lt;b&gt;title&lt;/b&gt;: Feature 2&lt;br /&gt;&lt;b&gt;author&lt;/b&gt;: Your Name Here</content><georss:polygon>-5.9765625 -131.484375 -58.0078125 -112.5 -50.2734375 -32.34375 52.3828125 -114.609375 -35.5078125 -167.34375 -57.3046875 -146.953125 -34.1015625 -139.921875 -5.9765625 -131.484375</georss:polygon></entry>', var input = ['<entry><id>http://featureserver.org/featureserver.cgi/scribble/562.atom</id><link href="http://featureserver.org/featureserver.cgi/scribble/562.atom"/><title>Feature 2</title><content type="html">&lt;b&gt;strokeColor&lt;/b&gt;: red&lt;br /&gt;&lt;b&gt;title&lt;/b&gt;: Feature 2&lt;br /&gt;&lt;b&gt;author&lt;/b&gt;: Your Name Here</content><georss:polygon>-5.9765625 -131.484375 -58.0078125 -112.5 -50.2734375 -32.34375 52.3828125 -114.609375 -35.5078125 -167.34375 -57.3046875 -146.953125 -34.1015625 -139.921875 -5.9765625 -131.484375</georss:polygon></entry>',