Click to See Complete Forum and Search --> : Using COM object's with PHP?


Anon
08-09-2000, 04:09 AM
Hi,

Is anybody familiar with how to use COM objects in PHP? I made a litle test code and everithing is seems to work fine, except when I trie to call function in COM object. Does anybody know how to do this?

Why I'm getting
"Warning: Invoke() failed: Type mismatch."
message when i try to call function in COM object???

What Am I doing wrong?

Simon

Here is the example code:

<?php
// Set the source and style sheet locations here
$root = "c:\inetpub\wwwroot\simple\\";

$sourceFile = $root."simple.xml";
$styleFile = $root."simple.xsl";

// Load the XML
$source = new COM( "Microsoft.XMLDOM" ) or die( "Cant read Microsoft.XMLDOM" );
$source->async = false;
$source->load( $sourceFile );

// Load the XSL
$style = new COM( "Microsoft.XMLDOM" ) or die( "Cant read Microsoft.XMLDOM" );
$style->async = false;
$style->load( $styleFile );

// set up the resulting document
$result = new COM( "Microsoft.XMLDOM" ) or die( "Cant read Microsoft.XMLDOM" );
$result->async = false;
$result->validateOnParse = true;

// parse results into a result DOM Document
//com_invoke( $source, "transformNodeToObject", $style, $result );
$source->transformNodeToObject( $style, $result );

echo $result;
?>

Anon
09-14-2000, 07:42 AM
actually i am a biginner in php i am now able to enable allow_dcom directive in configuration please help regarding this topic i have seen this from phpinfo() function.

Anon
09-15-2000, 06:43 PM
I got badly burned by assuming that MS ASP pages destroyed COM objects created on a page. I am now experimenting with PHP and the person who got me started claims that PHP destroys all COM objects at the end of each page. Is this ABSOLUTELY 100% true?

As extra insurance, how do I explicitly destroy a COM object?

What I cannot afford is for COM objects to be left dangling in the system.

Thanks...

Anon
11-09-2000, 12:12 PM
Hi,

I'm quite sure PHP does not automatically
destroy the COM-objects. [It didn't on
my system anyway.]


// Fredrik

Anon
05-17-2001, 05:33 AM
well i am myself foxed with the same problem!!

What i am trying to do is to create object of Microsoft.XMLDOM and then load an XML file and XSL file to display the results in the browser(in effect using XSL +XML at server)

the client side equivalent is attached to give you an idea.

Please let me know whether this is possible or not??
thanks

PS:
============================================

<body>
<script type="text/javascript">
// Load XML
var xml = new ActiveXObject("Microsoft.XMLDOM")
xml.async = false
xml.load("cd_catalog.xml")

// Load the XSL
var xsl = new ActiveXObject("Microsoft.XMLDOM")
xsl.async = false
xsl.load("cd_catalog.xsl")

// Transform
document.write(xml.transformNode(xsl))
</script>

</body>

Anon
07-23-2001, 05:34 AM
So you can destroy an object

$myObj = null;


:-)

Anon
11-12-2001, 11:23 PM
I am having the same problem. If you find the solution please let me know, I will do the same. I can output the xml with "print($myXML->xml);" and if the document has a processing instruction I just get the text of the document. Even if I set the header to text/xml. The funny thing is methods like "$myXML->selectSingleNode('book')" seem to work fine, it's just transformNode that chokes??????