tags:

views:

267

answers:

2

So let me apologize right up front. I'm not a PHP programmer, I'm a C# programmer. But I have to support a website that was written for my company in PHP and is falling apart. So here's my simple question:

I have the following code:

xml_doc = new ActiveXObject("Microsoft.XMLDOM");
xml_doc.async = false;
url = "./viewInvoiceXML.php?soh_id=<? echo($soh_id)  ?>";

xml_doc.load(url);
xmlObj = xml_doc.documentElement;

Later in the page, I'm displaying some XML nodes out. I'm needing to see all the XML thats returned so I can find the right nodes that need to be displayed.

How do I print to the page this xml_doc or xmlObj? I'd just like to see all XML (tags and all). Is this possible?

------------Update-----------------

Well, as many of you have point out, its JScript that might be creating the ActiveXObject.

If its JScript, then I'm needing a way in JScript to show me the XML information. I'm telling you, I don't know much about this website at all.

Here's the other code that is getting the information out of the XML node.

xmlObj.childNodes(1).childNodes(0).childNodes(6).text
A: 

print_r($var) or var_dump($var) should do you for output PHP variables.

dnagirl
+2  A: 

First of all, in your code example PHP code and JScript code are mixed. Only <? echo ... ?> is actual PHP. The rest is plain JScript which is output to the browser, where it's then interpreted.

EDIT: It's not JavaScript, it's JScript. For example there's no ActiveXObject class in standard JavaScript.

Because of that you cannot use PHP to display the XML code. You have write something which will work in the browser. Try adding this:

<code>
  <pre>
    <script language="JScript">
     document.write(xml_doc.xml);
    </script>
  </pre>
</code>

Essentially this adds some fixed HTML tags (code, pre) and a JScript command to output a string to the HTML page. xml is a property provided by the XMLDOM object, which returns the XML source representation.

DR