18 January 2026:


This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.



Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.

XML read issue

ashleyd182ashleyd182 Members
edited November -1 in Sahi - Open Source
Hi All,

I am trying to validate a XML message for its content and was encountering the below issue.
TypeError: The processing instruction target matching "[xX][mM][lL]" is not allowed. at Nov 19, 2010 5:09:16 PM

Once I removed the below line I was able to read and use var $x = new XML(xmlStr); without any problem.
line removed (this was on the first line):
<?xml version="1.0" encoding="UTF-8"?>

Can someone let me know what is the solution to this problem, because the XML file I would receive will always contain the above tag?

Thanks,
Ashley

Comments

  • narayannarayan Administrators
    Hi Ashley,

    Where are you getting this XML from? Could you alert or debug the xmlStr and see if it has Sahi's injected code in it?

    Regards,
    Narayan
  • Hi Narayan,

    Thanks for your reply.

    I am getting this xml created as a by-product of a outbound data exchange. This xml needs to be validated to ensure it contains all data from the front-end.

    Currently, I tried to alert the xml and it gives me a [object Object] message.

    Any suggestions?

    I was able to successfully test your example xml.

    Appreciate your help.

    Thanks,
    Ashley
  • Hi Narayan,

    Here is a sample of the modified xml I am trying to validate.

    var xmlStr1 = '' +
    '<ns0:employee xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"; xmlns:ns0="XX">' +
    ' <ns1:person xmlns:ns1="a">' +
    ' <name>Ant</name>' +
    ' <hair>Shaggy</hair>' +
    ' <eyes>Blue</eyes>' +
    ' <height measure="metric">176</height>' +
    ' </ns1:person>' +
    ' <ns1:person xmlns:ns1="b">' +
    ' <name>Paul</name>' +
    ' <hair>Spiky</hair>' +
    ' <eyes>Grey</eyes>' +
    ' <height measure="metric">178</height>' +
    ' </ns1:person>' +
    '</ns0:employee>';


    I get a blank alert ("") when I perform:
    var $x = new XML(xmlStr1);
    _alert($x.toString());
    _alert($x.ns1.name.toString());

    Thanks,
    Ashley
  • Hi Narayan,

    I got stuck with the same issue. My xml file always containing above tag and while parsing it i got same error. Can you throw some light on this?

    JSERROR
    TypeError: The processing instruction target matching "[xX][mM][lL]" is not allowed. at Jan 5, 2011 3:05:51 PM
  • Hi Narayan,
    i am also facing same issue.MY xml file containing the tag as <?xml version="1.0" encoding="UTF-8" ?>

    and my code is :
    var $XMLStr = _readFile("E:\\Sahi\\userdata\\BCS-OracleArLogPFR-SO.xml");
    var $x = new XML($XMLStr);
    _alert($x);

    TypeError: The processing instruction target matching "[xX][mM][lL]" is not allowed.

    If i am removing the tag: <?xml version="1.0" encoding="UTF-8" ?>
    its working fine, but we required this tag .Kindly provide me the solution.
Sign In or Register to comment.