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

时间:2014-10-08 12:28:02

标签: javascript xml

以下是场景: 我试图在函数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.
}

1 个答案:

答案 0 :(得分:0)

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.
}