diff --git a/src/ol/format/gml/gmlbaseformat.js b/src/ol/format/gml/gmlbaseformat.js
index 1878296f8f..a65717cff8 100644
--- a/src/ol/format/gml/gmlbaseformat.js
+++ b/src/ol/format/gml/gmlbaseformat.js
@@ -203,10 +203,11 @@ ol.format.GMLBase.prototype.readFeatureElement = function(node, objectStack) {
n = n.nextElementSibling) {
var localName = ol.xml.getLocalName(n);
// Assume attribute elements have one child node and that the child
- // is a text node. Otherwise assume it is a geometry node.
+ // is a text or CDATA node (to be treated as text).
+ // Otherwise assume it is a geometry node.
if (n.childNodes.length === 0 ||
(n.childNodes.length === 1 &&
- n.firstChild.nodeType === 3)) {
+ (n.firstChild.nodeType === 3 || n.firstChild.nodeType === 4))) {
var value = ol.xml.getAllTextContent(n, false);
if (goog.string.isEmpty(value)) {
value = undefined;
diff --git a/test/spec/ol/format/gmlformat.test.js b/test/spec/ol/format/gmlformat.test.js
index 8597ad26ce..0080cbed75 100644
--- a/test/spec/ol/format/gmlformat.test.js
+++ b/test/spec/ol/format/gmlformat.test.js
@@ -907,6 +907,47 @@ describe('ol.format.GML3', function() {
});
});
+ describe('when parsing CDATA attribute', function() {
+ var features;
+ before(function(done) {
+ try {
+ var text =
+ '' +
+ ' ' +
+ ' Aflu' +
+ ' ' +
+ ' ' +
+ ' 34.12 2.09' +
+ ' ' +
+ ' ' +
+ ' 84683' +
+ ' Algeria' +
+ ' place' +
+ ' Aflu' +
+ ' b]]>' +
+ ' ' +
+ '';
+ var config = {
+ 'featureNS': 'http://www.openplans.org/topp',
+ 'featureType': 'gnis_pop'
+ };
+ features = new ol.format.GML(config).readFeatures(text);
+ } catch (e) {
+ done(e);
+ }
+ done();
+ });
+
+ it('creates 1 feature', function() {
+ expect(features).to.have.length(1);
+ });
+
+ it('converts XML attribute to text', function() {
+ expect(features[0].get('cdata')).to.be('b');
+ });
+ });
+
describe('when parsing TOPP states WFS with autoconfigure', function() {
var features, text, gmlFormat;
before(function(done) {