diff --git a/lib/OpenLayers/Format/GML.js b/lib/OpenLayers/Format/GML.js
index 36d8f5352c..efe1f9ef31 100644
--- a/lib/OpenLayers/Format/GML.js
+++ b/lib/OpenLayers/Format/GML.js
@@ -453,7 +453,8 @@ OpenLayers.Format.GML = OpenLayers.Class(OpenLayers.Format.XML, {
grandchildren = child.childNodes;
if(grandchildren.length == 1) {
grandchild = grandchildren[0];
- if(grandchild.nodeType == 3) {
+ if(grandchild.nodeType == 3 ||
+ grandchild.nodeType == 4) {
name = (child.prefix) ?
child.nodeName.split(":")[1] :
child.nodeName;
diff --git a/lib/OpenLayers/Format/KML.js b/lib/OpenLayers/Format/KML.js
index 3dd4db14b5..2f64c23b3b 100644
--- a/lib/OpenLayers/Format/KML.js
+++ b/lib/OpenLayers/Format/KML.js
@@ -326,7 +326,7 @@ OpenLayers.Format.KML = OpenLayers.Class(OpenLayers.Format.XML, {
grandchildren = child.childNodes;
if(grandchildren.length == 1) {
grandchild = grandchildren[0];
- if(grandchild.nodeType == 3) {
+ if(grandchild.nodeType == 3 || grandchild.nodeType == 4) {
name = (child.prefix) ?
child.nodeName.split(":")[1] :
child.nodeName;
@@ -638,4 +638,4 @@ OpenLayers.Format.KML = OpenLayers.Class(OpenLayers.Format.XML, {
},
CLASS_NAME: "OpenLayers.Format.KML"
-});
\ No newline at end of file
+});
diff --git a/tests/Format/test_GML.html b/tests/Format/test_GML.html
index f142d01e96..601e9c7dc7 100644
--- a/tests/Format/test_GML.html
+++ b/tests/Format/test_GML.html
@@ -147,13 +147,14 @@
t.eq(data[0].geometry.components.length, 2, "rings length correct");
}
function test_Format_GML_read_attributes(t) {
- t.plan(1);
+ t.plan(2);
var parser = new OpenLayers.Format.GML();
data = parser.read(test_content[0]);
t.eq(data[0].attributes['NAME'], "WY", "Simple Attribute data is read correctly.");
+ t.eq(data[0].attributes['LONGNAME'], "Wyoming", "Attribute data is read from CDATA node correctly.");
}
- var test_content = ['\n\n \n \n -1254041.389711702250906.9515983529\n -634517.1199908922762236.2940800377\n \n \n \n \n -634517.11999089224,691849.77929356066,0 -653761.64509297756,471181.53429472551,0 -673343.60852865304,250906.9515983529,0 -1088825.734430399,299284.85108220269,0 -1254041.3897117018,324729.27754874947,0 -1235750.4212498858,434167.33911316615,0 -1190777.7803201093,704392.96327195223,0 -1181607.835811228,762236.29408003774,0 -634517.11999089224,691849.77929356066,0\n WY\n \n \n\n',
+ var test_content = ['\n\n \n \n -1254041.389711702250906.9515983529\n -634517.1199908922762236.2940800377\n \n \n \n \n -634517.11999089224,691849.77929356066,0 -653761.64509297756,471181.53429472551,0 -673343.60852865304,250906.9515983529,0 -1088825.734430399,299284.85108220269,0 -1254041.3897117018,324729.27754874947,0 -1235750.4212498858,434167.33911316615,0 -1190777.7803201093,704392.96327195223,0 -1181607.835811228,762236.29408003774,0 -634517.11999089224,691849.77929356066,0\n WY\n \n \n \n\n',
'