(xmlDoc, tagName, i)
| 7 | * @param {number} i : start index |
| 8 | */ |
| 9 | export function readStopNode(xmlDoc, tagName, i){ |
| 10 | const startIndex = i; |
| 11 | // Starting at 1 since we already have an open tag |
| 12 | let openTagCount = 1; |
| 13 | |
| 14 | for (; i < xmlDoc.length; i++) { |
| 15 | if( xmlDoc[i] === "<"){ |
| 16 | if (xmlDoc[i+1] === "/") {//close tag |
| 17 | const closeIndex = findSubStrIndex(xmlDoc, ">", i, `${tagName} is not closed`); |
| 18 | let closeTagName = xmlDoc.substring(i+2,closeIndex).trim(); |
| 19 | if(closeTagName === tagName){ |
| 20 | openTagCount--; |
| 21 | if (openTagCount === 0) { |
| 22 | return { |
| 23 | tagContent: xmlDoc.substring(startIndex, i), |
| 24 | i : closeIndex |
| 25 | } |
| 26 | } |
| 27 | } |
| 28 | i=closeIndex; |
| 29 | } else if(xmlDoc[i+1] === '?') { |
| 30 | const closeIndex = findSubStrIndex(xmlDoc, "?>", i+1, "StopNode is not closed.") |
| 31 | i=closeIndex; |
| 32 | } else if(xmlDoc.substr(i + 1, 3) === '!--') { |
| 33 | const closeIndex = findSubStrIndex(xmlDoc, "-->", i+3, "StopNode is not closed.") |
| 34 | i=closeIndex; |
| 35 | } else if(xmlDoc.substr(i + 1, 2) === '![') { |
| 36 | const closeIndex = findSubStrIndex(xmlDoc, "]]>", i, "StopNode is not closed.") - 2; |
| 37 | i=closeIndex; |
| 38 | } else { |
| 39 | const tagData = readTagExp(xmlDoc, i, '>') |
| 40 | |
| 41 | if (tagData) { |
| 42 | const openTagName = tagData && tagData.tagName; |
| 43 | if (openTagName === tagName && tagData.tagExp[tagData.tagExp.length-1] !== "/") { |
| 44 | openTagCount++; |
| 45 | } |
| 46 | i=tagData.closeIndex; |
| 47 | } |
| 48 | } |
| 49 | } |
| 50 | }//end for loop |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * Read closing tag name |
nothing calls this directly
no test coverage detected