From: Lee T. <lee...@pl...> - 2001-05-08 21:21:13
|
----- In reply to "Re: [Tclxml-users] tcldompro.c" from Joe English <jen...@fl...> ----- > > Lee Teague <lee...@pl...> wrote: > > > Here's what I'm trying to do: > > with the tcl version: > > %set doc [dom::DOMImplementation create] > > ::dom::document1(node1) > > > > the C version: > > %set doc [dom::DOMImplementation create] > > node9 > > > > with the tcl version, I can then take $doc and run "dom::DOMImplementation > > serialize" on it to create the xml. But, with the C version, it says, "document > > has no document element" > > That's odd; the Tcl version gives me the same error as the C version > ("document has no document element"). What version of dom::tcl do you > have installed? > > You need to create a root element node before serializing the > document; things should work properly then. > So how do I create a "root element"? With the TCL version, all my code works fine, but with this C version, it complains about "no document element". I'll include a code snippet at the bottom of this msg to show you exactly what's happening. Again, the TCL version creates the XML just fine like this. Thanks for your help! --------- CODE THAT WORKS WITH THE TCL VERSION ------------------- set methodName "get_state" set doc [dom::DOMImplementation create] set env [dom::document createElement $doc "SOAP-ENV:Envelope"] dom::element setAttribute $env "xmlns:SOAP-ENV" "http://schemas.xmlsoap.org/soap/envelope/" dom::element setAttribute $env "xmlns:xsi" "http://www.w3.org/1999/XMLSchema-instance" dom::element setAttribute $env "xmlns:xsd" "http://www.w3.org/1999/XMLSchema" set bod [dom::document createElement $env "SOAP-ENV:Body"] set cmd [dom::document createElement $bod $methodName] dom::element setAttribute $cmd "SOAP-ENV:encodingStyle" "http://schemas.xmlsoap.org/soap/encoding/" set par [dom::document createElement $cmd state] dom::element setAttribute $par "xsi:type" "xsd:string" dom::document createTextNode $par Texas regsub {<!DOCTYPE[^>]*>\n} [dom::DOMImplementation serialize $doc] {} result dom::DOMImplementation destroy $doc return $result --------- CODE THAT WORKS WITH THE TCL VERSION ------------------ -------------- XML RESULT FROM TCL VERSION ---------------------- <?xml version='1.0'?> <SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/1999/XMLSchema"> <SOAP-ENV:Body> <get_state SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <state xsi:type="xsd:string"> Texas </state> </get_state> </SOAP-ENV:Body> </SOAP-ENV:Envelope> -------------- XML RESULT FROM TCL VERSION ---------------------- -- Lee Teague Placemark Investments lee...@pl... |