I am trying to remove some lines that represent some XML elements from a file. The user has a simple & lt; Input type = "file" & gt; Provides a file using
tag, and is read as text with this file from FileReader
, and given in the form of the parameter:
This approach works fine with few matches in the input text file, but a file of 1.5 MB is given, the script has been stuck (with Google Chrome running) , Tab to make it non-responsive) There are approximately one million "relevant elements" in this file, which means the corresponds to the relevant delimiter
.
How can I customize it?
Replace "code" instead of "code moving it out of the input" Instead of calling you, you use the second argument: fromIndex
. In this way, it searches for the next spot after the given index, and you can loop through a very large input without the need to touch it.
function dealWithString (invalidXML) {var validXML = ""; {Var delimiter = relatedDelimiters [i], pos = 0, startPos; for var i = 0; i & lt; contextual delimiter lamps; i ++) While ((startPos = invalidXML.indexOf (delimiter.begin, pos))! = -1) {// The relevant elements of this type of left are: var endPos = invalidXML.indexOf (delimiter.end, startPos); // Insert (And Piece! = -1) - Otherwise this could be a very bad situation = Endos + delimiter.and.line; // Attach to finish the result: Valid XML + = invalidXML.slice (startPos, pos) + "\ n"; }} Valid XML return; }
No comments:
Post a Comment