Re: [PHP] DOMDocument-saveXML()
On Sun, September 17, 2006 3:48 pm, Chris Boget wrote: Would it be possible to point to the relevant page in the documentation that discusses how to do this? If there is nothing builtin to do it, how tricky could it be to strip off the first line after you saved it?... Crude, but effective, Captain -- Spock -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] DOMDocument-saveXML()
Would it be possible to point to the relevant page in the documentation that discusses how to do this? If there is nothing builtin to do it, how tricky could it be to strip off the first line after you saved it?... Not tricky at all. Crude, but effective, Captain -- Spock Exactly. I was just hoping for something a bit more elegant. Hopefully using something that was built in to DOMDocument. Oh, well. thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] DOMDocument-saveXML()
Perhaps you missed my reply. http://www.php.net/manual/en/function.dom-domdocument-savexml.php The first parameter to DOMDocument-saveXML() is described: Use this parameter to output only a specific node without XML declaration rather than the entire document. If you pass the root node then you get the entire document without the XML declaration. That's both elegant and built-in. Tom. Chris Boget wrote: Would it be possible to point to the relevant page in the documentation that discusses how to do this? If there is nothing builtin to do it, how tricky could it be to strip off the first line after you saved it?... Not tricky at all. Crude, but effective, Captain -- Spock Exactly. I was just hoping for something a bit more elegant. Hopefully using something that was built in to DOMDocument. Oh, well. thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] DOMDocument-saveXML()
Perhaps you missed my reply. If you pass the root node then you get the entire document without the XML declaration. That's both elegant and built-in. I didn't miss it. But you have to pass in the root DomNode object. The only way to get it is by doing the following: $nodeList = $doc-getElementsByTagname( 'RootTagName' ); echo $doc-saveXML( $nodeList-item( 0 )); So unless your root node has an ID, that seems pretty excessive. Now you have the wasted resources that $nodeList is using. While it is crude, I believe it is both faster and less resource intensive to just do: echo str_replace( '?xml version=1.0?', '', $doc-saveXML()); It would be really nice if you could also specify a string value -- the name of the root node. I do appreciate the time and effort in reply to my post. It forced me to relook at the method and to look into DomNode and DomNodeList. :) thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] DOMDocument-saveXML()
Chris Boget wrote: Perhaps you missed my reply. If you pass the root node then you get the entire document without the XML declaration. That's both elegant and built-in. In the future there will be an save option to perform this. This was only made possible in recent libxml releases so has not been enabled yet in DOM (although the constant has been defined in ext/libxml). I didn't miss it. But you have to pass in the root DomNode object. The only way to get it is by doing the following: $nodeList = $doc-getElementsByTagname( 'RootTagName' ); echo $doc-saveXML( $nodeList-item( 0 )); echo $doc-saveXML($doc-documentElement); So unless your root node has an ID, that seems pretty excessive. Now you have the wasted resources that $nodeList is using. While it is crude, I believe it is both faster and less resource intensive to just do: echo str_replace( '?xml version=1.0?', '', $doc-saveXML()); Doing that (although it wont work if encoding is also output in xml declaration) also maintains document encoding. Doing the previous will output the document element and its subtree in UTF-8 (of course this is to be expected as you are dropping any possibility of providing an indication of the encoding) It would be really nice if you could also specify a string value -- the name of the root node. Why? documentElement property works just fine and is much more flexible. Rob -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] DOMDocument-saveXML()
Why? documentElement property works just fine and is much more flexible. Where can you find a list of properties for the object? I don't see anything like this in the documentation. Doing a search: http://us3.php.net/manual-lookup.php?pattern=DOMDocumentlang=en only returns the methods. Clicking on any one of the methods gives you a list of all the other methods (along with associated objects) in the right hand navigation menu but it doesn't have anything about the properties. thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] DOMDocument-saveXML()
On Mon, 2006-09-18 at 20:33 -0400, Chris Boget wrote: Why? documentElement property works just fine and is much more flexible. Where can you find a list of properties for the object? I don't see anything like this in the documentation. Doing a search: http://us3.php.net/manual-lookup.php?pattern=DOMDocument〈=en only returns the methods. Clicking on any one of the methods gives you a list of all the other methods (along with associated objects) in the right hand navigation menu but it doesn't have anything about the properties. Click on one of th edom methods... when you get to the details page for that method, see the left navigation menu, at the very top is a link to the class details which contains information about the properties: http://us3.php.net/manual/en/ref.dom.php Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] DOMDocument-saveXML()
Click on one of th edom methods... when you get to the details page for that method, see the left navigation menu, at the very top is a link to the class details which contains information about the properties: http://us3.php.net/manual/en/ref.dom.php Excellent. Thank you very much! :) thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php