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

Function readPI

src/validator.js:201–219  ·  view source on GitHub ↗

* Read Processing insstructions and skip * @param {*} xmlData * @param {*} i

(xmlData, i)

Source from the content-addressed store, hash-verified

199 * @param {*} i
200 */
201function readPI(xmlData, i) {
202 const start = i;
203 for (; i < xmlData.length; i++) {
204 if (xmlData[i] == '?' || xmlData[i] == ' ') {
205 //tagname
206 const tagname = xmlData.substr(start, i - start);
207 if (i > 5 && tagname === 'xml') {
208 return getErrorObject('InvalidXml', 'XML declaration allowed only at the start of the document.', getLineNumberForPosition(xmlData, i));
209 } else if (xmlData[i] == '?' && xmlData[i + 1] == '>') {
210 //check if valid attribut string
211 i++;
212 break;
213 } else {
214 continue;
215 }
216 }
217 }
218 return i;
219}
220
221function readCommentAndCDATA(xmlData, i) {
222 if (xmlData.length > i + 5 && xmlData[i + 1] === '-' && xmlData[i + 2] === '-') {

Callers 1

validateFunction · 0.85

Calls 2

getErrorObjectFunction · 0.85
getLineNumberForPositionFunction · 0.85

Tested by

no test coverage detected