MCPcopy Create free account
hub / github.com/NaturalIntelligence/fast-xml-parser / readAttributeStr

Function readAttributeStr

src/validator.js:280–310  ·  view source on GitHub ↗

* Keep reading xmlData until '<' is found outside the attribute value. * @param {string} xmlData * @param {number} i

(xmlData, i)

Source from the content-addressed store, hash-verified

278 * @param {number} i
279 */
280function readAttributeStr(xmlData, i) {
281 let attrStr = '';
282 let startChar = '';
283 let tagClosed = false;
284 for (; i < xmlData.length; i++) {
285 if (xmlData[i] === doubleQuote || xmlData[i] === singleQuote) {
286 if (startChar === '') {
287 startChar = xmlData[i];
288 } else if (startChar !== xmlData[i]) {
289 //if vaue is enclosed with double quote then single quotes are allowed inside the value and vice versa
290 } else {
291 startChar = '';
292 }
293 } else if (xmlData[i] === '>') {
294 if (startChar === '') {
295 tagClosed = true;
296 break;
297 }
298 }
299 attrStr += xmlData[i];
300 }
301 if (startChar !== '') {
302 return false;
303 }
304
305 return {
306 value: attrStr,
307 index: i,
308 tagClosed: tagClosed
309 };
310}
311
312/**
313 * Select all the attributes whether valid or invalid.

Callers 1

validateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected