XML PHP problem help!

Discussion in 'HTML & Website Design' started by ecigazon, Feb 10, 2010.

  1. #1
    Here's what I'm trying to do, and I think I know the problem but not how to get around it.

    I'm generating an xml markup. The syntax below works fine.

    <xmlresponse>
    <transaction>
    <transactionID><? echo $transactionID ?></transactionID>
    <resultNumber><? echo $resultNumber ?></resultNumber>
    <result><? echo $result ?></result>
    <code><? echo $code ?></code>
    </transaction>
    </xmlresponse>

    ...but I'd like to add another XML element called form. Which will be an html form that I build server side. So the code will look something like this.

    <xmlresponse>
    <transaction>
    <transactionID><? echo $transactionID ?></transactionID>
    <resultNumber><? echo $resultNumber ?></resultNumber>
    <result><? echo $result ?></result>
    <code><? echo $code ?></code>
    <myform>
    <? echo '<form>' ?>
    <? echo '....' ?>
    <? echo '....' ?>
    <? echo '</form>' ?>
    </myform>
    </transaction>
    </xmlresponse>

    This works fine displayed as text if I execute directly against the PHP page. The problem is that when I try and get the XML response in ajax on my client page the DOM comes back as null.

    I've managed to figure out the reason it does this is the html markup, e.g. <form>, <input>, etc, messes up the XML markup. I've figured out there could be 2 solutions to this problem, but I'm not sure if one of them is possible.

    1. Is there a way to override the XML markup. Meaning is there a flag I could set that would make the XML DOM ignore everything it thinks is XML within the brackets <myform> </myform>? In essence treating it as some sort of blob that it doesn't care about?

    The other way I've come up with is possible, but not ideal as it will be extremely messy and require character swapping on both client and server.
     
    ecigazon, Feb 10, 2010 IP