fast-xml-parser
Advanced tools
Comparing version 2.7.3 to 2.7.4
@@ -21,2 +21,3 @@ var getAllMatches = require("./util").getAllMatches; | ||
attrPrefix : "@_", | ||
attrNodeName: false, | ||
textNodeName : "#text", | ||
@@ -34,3 +35,3 @@ ignoreNonTextNodeAttr : true, | ||
if(!options) options = {}; | ||
var props = ["attrPrefix","ignoreNonTextNodeAttr","ignoreTextNodeAttr","ignoreNameSpace","ignoreRootElement","textNodeName","textNodeConversion","textAttrConversion","arrayMode"]; | ||
var props = ["attrPrefix","attrNodeName","ignoreNonTextNodeAttr","ignoreTextNodeAttr","ignoreNameSpace","ignoreRootElement","textNodeName","textNodeConversion","textAttrConversion","arrayMode"]; | ||
for (var i = 0; i < props.length; i++) { | ||
@@ -65,7 +66,7 @@ if(options[props[i]] === undefined){ | ||
if(selfClosingTag){ | ||
attrs = buildAttributesArr(attrsStr,options.ignoreTextNodeAttr,options.attrPrefix,options.ignoreNameSpace,options.textAttrConversion); | ||
attrs = buildAttributesArr(attrsStr,options.ignoreTextNodeAttr,options.attrPrefix,options.attrNodeName,options.ignoreNameSpace,options.textAttrConversion); | ||
childNode.val = attrs || ""; | ||
currentNode.addChild(childNode); | ||
}else if( ("/" + tag) === nexttag){ //Text node | ||
attrs = buildAttributesArr(attrsStr,options.ignoreTextNodeAttr,options.attrPrefix,options.ignoreNameSpace,options.textAttrConversion); | ||
attrs = buildAttributesArr(attrsStr,options.ignoreTextNodeAttr,options.attrPrefix,options.attrNodeName,options.ignoreNameSpace,options.textAttrConversion); | ||
val = parseValue(val,options.textNodeConversion); | ||
@@ -85,3 +86,3 @@ if(attrs){ | ||
}else{//starting tag | ||
attrs = buildAttributesArr(attrsStr,options.ignoreNonTextNodeAttr,options.attrPrefix,options.ignoreNameSpace,options.textAttrConversion); | ||
attrs = buildAttributesArr(attrsStr,options.ignoreNonTextNodeAttr,options.attrPrefix,options.attrNodeName,options.ignoreNameSpace,options.textAttrConversion); | ||
if(attrs){ | ||
@@ -147,3 +148,3 @@ for (var prop in attrs) { | ||
var attrsRegx = new RegExp("(\\S+)\\s*=\\s*(['\"])(.*?)\\2","g"); | ||
function buildAttributesArr(attrStr,ignore,prefix,ignoreNS,conversion){ | ||
function buildAttributesArr(attrStr,ignore,prefix,attrNodeName,ignoreNS,conversion){ | ||
attrStr = attrStr || attrStr.trim(); | ||
@@ -155,5 +156,9 @@ | ||
var attrs = {}; | ||
var attrsCollection = attrs; | ||
if(attrNodeName && matches.length){ | ||
attrsCollection = attrs[attrNodeName] = {}; | ||
} | ||
for (var i = 0; i < matches.length; i++) { | ||
var attrName = prefix + resolveNameSpace( matches[i][1],ignoreNS); | ||
attrs[attrName] = parseValue(matches[i][3],conversion); | ||
attrsCollection[attrName] = parseValue(matches[i][3],conversion); | ||
} | ||
@@ -160,0 +165,0 @@ return attrs; |
@@ -22,2 +22,3 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.parser = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
attrPrefix : "@_", | ||
attrNodeName: false, | ||
textNodeName : "#text", | ||
@@ -35,3 +36,3 @@ ignoreNonTextNodeAttr : true, | ||
if(!options) options = {}; | ||
var props = ["attrPrefix","ignoreNonTextNodeAttr","ignoreTextNodeAttr","ignoreNameSpace","ignoreRootElement","textNodeName","textNodeConversion","textAttrConversion","arrayMode"]; | ||
var props = ["attrPrefix","attrNodeName","ignoreNonTextNodeAttr","ignoreTextNodeAttr","ignoreNameSpace","ignoreRootElement","textNodeName","textNodeConversion","textAttrConversion","arrayMode"]; | ||
for (var i = 0; i < props.length; i++) { | ||
@@ -66,7 +67,7 @@ if(options[props[i]] === undefined){ | ||
if(selfClosingTag){ | ||
attrs = buildAttributesArr(attrsStr,options.ignoreTextNodeAttr,options.attrPrefix,options.ignoreNameSpace,options.textAttrConversion); | ||
attrs = buildAttributesArr(attrsStr,options.ignoreTextNodeAttr,options.attrPrefix,options.attrNodeName,options.ignoreNameSpace,options.textAttrConversion); | ||
childNode.val = attrs || ""; | ||
currentNode.addChild(childNode); | ||
}else if( ("/" + tag) === nexttag){ //Text node | ||
attrs = buildAttributesArr(attrsStr,options.ignoreTextNodeAttr,options.attrPrefix,options.ignoreNameSpace,options.textAttrConversion); | ||
attrs = buildAttributesArr(attrsStr,options.ignoreTextNodeAttr,options.attrPrefix,options.attrNodeName,options.ignoreNameSpace,options.textAttrConversion); | ||
val = parseValue(val,options.textNodeConversion); | ||
@@ -86,3 +87,3 @@ if(attrs){ | ||
}else{//starting tag | ||
attrs = buildAttributesArr(attrsStr,options.ignoreNonTextNodeAttr,options.attrPrefix,options.ignoreNameSpace,options.textAttrConversion); | ||
attrs = buildAttributesArr(attrsStr,options.ignoreNonTextNodeAttr,options.attrPrefix,options.attrNodeName,options.ignoreNameSpace,options.textAttrConversion); | ||
if(attrs){ | ||
@@ -148,3 +149,3 @@ for (var prop in attrs) { | ||
var attrsRegx = new RegExp("(\\S+)\\s*=\\s*(['\"])(.*?)\\2","g"); | ||
function buildAttributesArr(attrStr,ignore,prefix,ignoreNS,conversion){ | ||
function buildAttributesArr(attrStr,ignore,prefix,attrNodeName,ignoreNS,conversion){ | ||
attrStr = attrStr || attrStr.trim(); | ||
@@ -156,5 +157,9 @@ | ||
var attrs = {}; | ||
var attrsCollection = attrs; | ||
if(attrNodeName && matches.length){ | ||
attrsCollection = attrs[attrNodeName] = {}; | ||
} | ||
for (var i = 0; i < matches.length; i++) { | ||
var attrName = prefix + resolveNameSpace( matches[i][1],ignoreNS); | ||
attrs[attrName] = parseValue(matches[i][3],conversion); | ||
attrsCollection[attrName] = parseValue(matches[i][3],conversion); | ||
} | ||
@@ -161,0 +166,0 @@ return attrs; |
{ | ||
"name": "fast-xml-parser", | ||
"version": "2.7.3", | ||
"version": "2.7.4", | ||
"description": "Validate XML or Parse XML to JS/JSON very fast without C/C++ based libraries", | ||
@@ -48,2 +48,6 @@ "main": "./bin/parser.js", | ||
"url" : "https://github.com/EyesOnlyNet" | ||
}, | ||
{ | ||
"name" : "Vohmyanin Sergey Vasilevich", | ||
"url" : "http://delagen.livejournal.com" | ||
} | ||
@@ -50,0 +54,0 @@ ], |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
187182
591