1
I have a code that goes through a file . ofx for reading your markings. However, the code . ofx has a header that makes it impossible to read it (that is, for the javascript code to work I have to remove the header manually). Is there any way to establish the line to which javascript will start a function?
example of . ofx:
OFXHEADER:100
DATA:OFXSGML
VERSION:102
SECURITY:NONE
ENCODING:USASCII
CHARSET:1252
COMPRESSION:NONE
OLDFILEUID:NONE
NEWFILEUID:NONE
<OFX>
<SIGNONMSGSRSV1>
<SONRS>
<STATUS>
<CODE>0</CODE>
<SEVERITY>INFO</SEVERITY>
</STATUS>
I wanted my code to ignore the OFXHEADER:100
until NEWFILEUID:NONE
and only started working from the tag <OFX>
.
I’m using this code to capture the tags I want:
function loadOFXDoc() {
var reader = new XMLHttpRequest();
reader.onreadystatechange = function() {
if (reader.readyState == 4 && reader.status == 200) {
showContent(reader);
}
};
reader.open("GET", "sample.ofx", true);
reader.send();
}
function showContent(xml) {
var i;
var ofxDoc = xml.responseXML;
var table="<tr><th>Local</th><th>Valor</th></tr>";
var x = ofxDoc.getElementsByTagName("STMTTRN");
for (i = 0; i <x.length; i++) {
table += "<tr><td>" +
x[i].getElementsByTagName("MEMO")[0].childNodes[0].nodeValue +
"</td><td>" +
x[i].getElementsByTagName("TRNAMT")[0].childNodes[0].nodeValue +
"</td></tr>";
}
document.getElementById("demo").innerHTML = table;
}
loadOFXDoc();
If you receive this data in a date by ajax, you could turn it into a string, capture the header and delete it?
– Samir Braga
You can give an example of how you use the content (in case you have already filtered the part you want)?
– Sergio
You will have to handle this manually, especially if you are using a native function to process this content, which I believe is xml... But the interesting thing would be for you to post the code, because from what I understand, you are asking if it is possible to modify the behavior of a given function, without at least specifying what function this would be.....
– mau humor
Opa, moçada. Com esse código tenho uma tabela com dois colunas mostrando o local da compra e o valor. HOWEVER, this code only works if I take out the header of the .ofx. file. My goal is for the script itself to do this, ignore the header and just start reading from the tag
<OFX>
.– Inaldo Eleuterio
@Inaldoeleuterio my question is "You can give an example of how you use the content (in case you have already filtered the part you want)?"
– Sergio
@Sergio, I’m sorry but I don’t understand. How do I use the content? Okay, come on: the information I get is from the credit card. I was able to filter by the local purchase and price tags. They are shown in a div with two columns. Only. That would be it?
– Inaldo Eleuterio