Method: parseAttributes

Parameters:
node - {DOMElement}

Returns:
{Object} An attributes object.
167537
function(node) {
        var attributes = {};
       
        // Extended Data is parsed first.
        var edNodes = node.getElementsByTagName("ExtendedData");
        if (edNodes.length) {
            attributes = this.parseExtendedData(edNodes[0]);
        }
        
        // assume attribute nodes are type 1 children with a type 3 or 4 child
        var child, grandchildren, grandchild;
        var children = node.childNodes;

        for(var i=0, len=children.length; i<len; ++i) {
            child = children[i];
            if(child.nodeType == 1) {
                grandchildren = child.childNodes;
                if(grandchildren.length >= 1 && grandchildren.length <= 3) {
                    var grandchild;
                    switch (grandchildren.length) {
                        case 1:
                            grandchild = grandchildren[0];
                            break;
                        case 2:
                            var c1 = grandchildren[0];
                            var c2 = grandchildren[1];
                            grandchild = (c1.nodeType == 3 || c1.nodeType == 4) ?
                                c1 : c2;
                            break;
                        case 3:
                        default:
                            grandchild = grandchildren[1];
                            break;
                    }
                    if(grandchild.nodeType == 3 || grandchild.nodeType == 4) {
                        var name = (child.prefix) ?
                                child.nodeName.split(":")[1] :
                                child.nodeName;
                        var value = OpenLayers.Util.getXmlNodeValue(grandchild);
                        if (value) {
                            value = value.replace(this.regExes.trimSpace, "");
                            attributes[name] = value;
                        }
                    }
                } 
            }
        }
        return attributes;
    }
468371
function parseAttributes(attributes) {
  for (const prop in attributes) {
    // Parse boolean values
    if (attributes[prop] === '') {
      attributes[prop] = true;
    }
  }

  return attributes;
}
1329580
def parse(node)
      node.attributes.each do |key, value|
        case key
        when 'applyFont'
          @apply_font = attribute_enabled?(value)
        when 'applyBorder'
          @apply_border = attribute_enabled?(value)
        when 'applyFill'
          @apply_fill = attribute_enabled?(value)
        when 'applyNumberFormat'
          @apply_number_format = attribute_enabled?(value)
        when 'applyAlignment'
          @apply_alignment = attribute_enabled?(value)
        when 'fontId'
          @font_id = value.value.to_i
        when 'borderId'
          @border_id = value.value.to_i
        when 'fillId'
          @fill_id = value.value.to_i
        when 'numFmtId'
          @number_format_id = value.value.to_i
        when 'quotePrefix'
          @quote_prefix = attribute_enabled?(value)
        end
      end
      node.xpath('*').each do |node_child|
        case node_child.name
        when 'alignment'
          @alignment.parse(node_child) if @apply_alignment
        end
      end
      self
    end
81597
function getAttribs(node) {
          var attribs = {};

          each(dom.getAttribs(node), function (attr) {
            var name = attr.nodeName.toLowerCase();

            // Don't compare internal attributes or style
            if (name.indexOf('_') !== 0 && name !== 'style' && name.indexOf('data-') !== 0) {
              attribs[name] = dom.getAttrib(node, name);
            }
          });

          return attribs;
        }
250342
function(el) {
      (el.length > 0) && (el = el[0]);
      var orgAttributes = {};
      for (var i=0; i<el.attributes.length; i++) {
        var attr = el.attributes[i];
        orgAttributes[attr.name] = attr.value;
      }
      return orgAttributes;
    }
1071718
function (node) {
      var name = "";

      var n = this.html.indexOf("=", this.currentChar);
      if (n === -1) {
        this.currentChar = this.html.length;
      } else {
        // Read until a '=' character is hit; this will be the attribute key
        name = this.html.substring(this.currentChar, n);
        this.currentChar = n + 1;
      }

      if (!name)
        return;

      // After a '=', we should see a '"' for the attribute value
      var c = this.nextChar();
      if (c !== '"' && c !== "'") {
        this.error("Error reading attribute " + name + ", expecting '\"'");
        return;
      }

      // Read the attribute value (and consume the matching quote)
      var value = this.readString(c);

      node.attributes.push(new Attribute(name, value));

      return;
    }
1032743
def parse_properties(node):
    
    d = dict()
    for child in node.findall('properties'):
        for subnode in child.findall('property'):
            cls = None
            try:
                if "type" in subnode.keys():
                    module = importlib.import_module('builtins')
                    cls = getattr(module, subnode.get("type"))
            except AttributeError:
                logger.info("Type [} Not a built-in type. Defaulting to string-cast.")
            d[subnode.get('name')] = cls(subnode.get('value')) if cls is not None else subnode.get('value')
    return d
203290
def parse(node)
      @spacing.parse(node)
      node.attributes.each do |key, value|
        case key
        when 'algn'
          @align = value_to_symbol(value)
        when 'lvl'
          @level = value.value.to_i
        when 'indent'
          @indent = OoxmlSize.new(value.value.to_f, :emu)
        when 'marR'
          @margin_right = OoxmlSize.new(value.value.to_f, :emu)
        when 'marL'
          @margin_left = OoxmlSize.new(value.value.to_f, :emu)
        end
      end
      node.xpath('*').each do |node_child|
        case node_child.name
        when 'buSzPct'
          @numbering.size = node_child.attribute('val').value
        when 'buFont'
          @numbering.font = node_child.attribute('typeface').value
        when 'buChar'
          @numbering.symbol = node_child.attribute('char').value
        when 'buAutoNum'
          @numbering.type = node_child.attribute('type').value.to_sym
          @numbering.start_at = node_child.attribute('startAt').value if node_child.attribute('startAt')
        when 'framePr'
          @frame_properties = FrameProperties.new(parent: self).parse(node_child)
        when 'tabs'
          @tabs = Tabs.new(parent: self).parse(node_child)
        when 'tabLst'
          @tabs = Tabs.new(parent: self).parse(node_child)
        when 'ind'
          @indent = Indents.new(parent: self).parse(node_child)
        when 'rPr'
          @run_properties = RunProperties.new(parent: self).parse(node_child)
        when 'pBdr'
          @paragraph_borders = ParagraphBorders.new(parent: self).parse(node_child)
        when 'keepNext'
          @keep_next = true
        when 'sectPr'
          @section_properties = PageProperties.new(parent: self).parse(node_child, @parent, DocxParagraphRun.new)
        when 'spacing'
          @spacing = ParagraphSpacing.new(parent: self).parse(node_child)
        when 'jc'
          @justification = value_to_symbol(node_child.attribute('val'))
        when 'contextualSpacing'
          @contextual_spacing = option_enabled?(node_child)
        end
      end
      self
    end
38862
function getHTMLAttribute(node, attrName) {
	attrName = attrName.toLowerCase();
	return node && node.attributes.find(attr => attr.name.value.toLowerCase() === attrName);
}
1058427
function(node) {
        var attributes = {};
        var i, len, data, key;
        var dataNodes = node.getElementsByTagName("Data");
        for (i = 0, len = dataNodes.length; i < len; i++) {
            data = dataNodes[i];
            key = data.getAttribute("name");
            var ed = {};
            var valueNode = data.getElementsByTagName("value");
            if (valueNode.length) {
                ed['value'] = this.getChildValue(valueNode[0]);
            }
            if (this.kvpAttributes) {
                attributes[key] = ed['value'];
            } else {
                var nameNode = data.getElementsByTagName("displayName");
                if (nameNode.length) {
                    ed['displayName'] = this.getChildValue(nameNode[0]);
                }
                attributes[key] = ed;
            } 
        }
        var simpleDataNodes = node.getElementsByTagName("SimpleData");
        for (i = 0, len = simpleDataNodes.length; i < len; i++) {
            var ed = {};
            data = simpleDataNodes[i];
            key = data.getAttribute("name");
            ed['value'] = this.getChildValue(data);
            if (this.kvpAttributes) {
                attributes[key] = ed['value'];
            } else {
                ed['displayName'] = key;
                attributes[key] = ed;
            }
        }
        
        return attributes;    
    }
1169546
def parse_xml_node(self, node):
        '''

        '''
        self.id = node.getAttributeNS(RTS_NS, 'id')
        self._config_data = []
        for d in node.getElementsByTagNameNS(RTS_NS, 'ConfigurationData'):
            self._config_data.append(ConfigurationData().parse_xml_node(d))
        return self
562390
function parseXMLNode(node) {
  const parsedNode = {
    attributes: {},
    children: {},
    value: {},
  };

  parsedNode.value = parseNodeValue(node);

  if (node.attributes) {
    [...node.attributes].forEach((nodeAttr) => {
      if (nodeAttr.nodeName && nodeAttr.nodeValue !== undefined && nodeAttr.nodeValue !== null) {
        parsedNode.attributes[nodeAttr.nodeName] = nodeAttr.nodeValue;
      }
    });
  }

  if (node.childNodes) {
    [...node.childNodes]
      .filter((childNode) => childNode.nodeName.substring(0, 1) !== '#')
      .forEach((childNode) => {
        parsedNode.children[childNode.nodeName] = parseXMLNode(childNode);
      });
  }

  return parsedNode;
}
247782
def parse_xml(self, node):
        
        self._set_properties(node)
        self.extend(TiledObject(self.parent, child)
                    for child in node.findall('object'))

        return self
1223341
def parse(node)
      node.attributes.each do |key, value|
        case key
        when 'amt'
          @amount = OoxmlSize.new(value.value.to_f, :one_1000th_percent)
        end
      end
      self
    end
1357521
def parse_xml(self, node):
        
        self._set_properties(node)
        self.name = node.get('name', None)
        self.opacity = node.get('opacity', self.opacity)
        self.visible = node.get('visible', self.visible)
        image_node = node.find('image')
        self.source = image_node.get('source', None)
        self.trans = image_node.get('trans', None)
        return self
528971
function(node) {
        var atomAttrib = {};
        var value = null;
        var nodes = null;
        var attval = null;
        var atomns = this.namespaces.atom;
        
        // atomAuthor*
        this.parsePersonConstructs(node, "author", atomAttrib);
        
        // atomCategory*
        nodes = this.getElementsByTagNameNS(node, atomns, "category");
        if (nodes.length > 0) {
            atomAttrib.categories = [];
        }
        for (var i=0, ii=nodes.length; i<ii; i++) {
            value = {};
            value.term = nodes[i].getAttribute("term");
            attval = nodes[i].getAttribute("scheme");
            if (attval) { value.scheme = attval; }
            attval = nodes[i].getAttribute("label");
            if (attval) { value.label = attval; }
            atomAttrib.categories.push(value);
        }
        
        // atomContent?
        nodes = this.getElementsByTagNameNS(node, atomns, "content");
        if (nodes.length > 0) {
            value = {};
            attval = nodes[0].getAttribute("type");
            if (attval) {
                value.type = attval;
            }
            attval = nodes[0].getAttribute("src");
            if (attval) {
                value.src = attval;
            } else {
                if (value.type == "text" || 
                    value.type == "html" || 
                    value.type == null ) {
                    value.value = this.getFirstChildValue(
                                        node,
                                        atomns,
                                        "content",
                                        null
                                        );
                } else if (value.type == "xhtml" ||
                           value.type.match(/(\+|\/)xml$/)) {
                    value.value = this.getChildEl(nodes[0]);
                } else { // MUST be base64 encoded
                    value.value = this.getFirstChildValue(
                                        node,
                                        atomns,
                                        "content",
                                        null
                                        );
                }
                atomAttrib.content = value;
            }
        }
        
        // atomContributor*
        this.parsePersonConstructs(node, "contributor", atomAttrib);
        
        // atomId
        atomAttrib.id = this.getFirstChildValue(node, atomns, "id", null);
        
        // atomLink*
        nodes = this.getElementsByTagNameNS(node, atomns, "link");
        if (nodes.length > 0) {
            atomAttrib.links = new Array(nodes.length);
        }
        var oAtts = ["rel", "type", "hreflang", "title", "length"];
        for (var i=0, ii=nodes.length; i<ii; i++) {
            value = {};
            value.href = nodes[i].getAttribute("href");
            for (var j=0, jj=oAtts.length; j<jj; j++) {
                attval = nodes[i].getAttribute(oAtts[j]);
                if (attval) {
                    value[oAtts[j]] = attval;
                }
            }
            atomAttrib.links[i] = value;
        }
        
        // atomPublished?
        value = this.getFirstChildValue(node, atomns, "published", null);
        if (value) {
            atomAttrib.published = value;
        }
        
        // atomRights?
        value = this.getFirstChildValue(node, atomns, "rights", null);
        if (value) {
            atomAttrib.rights = value;
        }
        
        // atomSource? -- not implemented
        
        // atomSummary?
        value = this.getFirstChildValue(node, atomns, "summary", null);
        if (value) {
            atomAttrib.summary = value;
        }
        
        // atomTitle
        atomAttrib.title = this.getFirstChildValue(
                                node, atomns, "title", null
                                );
        
        // atomUpdated
        atomAttrib.updated = this.getFirstChildValue(
                                node, atomns, "updated", null
                                );
        
        var featureAttrib = {
            title: atomAttrib.title,
            description: atomAttrib.summary,
            atom: atomAttrib
        };
        var geometry = this.parseLocations(node)[0];
        var feature = new OpenLayers.Feature.Vector(geometry, featureAttrib);
        feature.fid = atomAttrib.id;
        return feature;
    }
600846
def parse(node)
      @id = node.attribute('id').value
      @type = node.attribute('type').value
      node.xpath('*').each do |text_field_node_child|
        case text_field_node_child.name
        when 't'
          @text = text_field_node_child.text
        end
      end
      self
    end