如何从一个函数中读取xml,该函数由javascript中的另一个函数加载

How to read the xml from one function which is loaded by another function in javascript

本文关键字:函数 javascript 加载 另一个 xml 读取 一个      更新时间:2023-09-26

下面是场景:我试图在函数B中读取的xmlDoc是全局声明的。

    function main()
{
   ...
   A(input xml);
...
B(other inputs);
}
function A(XML_input)
{
...
    var xmlDoc = FLEXWIN.GetData.dsoValidator1Resp.XMLDocument;
    xmlDoc.async = false;
    xmlDoc.loadXML(XML_input.xml);
}
function B(some other input)
{
    // I want to use the xmlDoc.xml here.. But its content is blank.
}
function main() {
    var xmlDoc = A(input_xml);
    B(xmlDoc, other_inputs);
}
function A(XML_input) {
    var xmlDoc = FLEXWIN.GetData.dsoValidator1Resp.XMLDocument;
    xmlDoc.async = false;
    xmlDoc.loadXML(XML_input.xml);
    return xmlDoc;
}
function B(xmlDoc, other_input) {
    //Etc.
}