* Keep reading xmlData until '<' is found outside the attribute value. * @param {string} xmlData * @param {number} i
(xmlData, i)
| 278 | * @param {number} i |
| 279 | */ |
| 280 | function 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. |