[PHP] DOM XML : set_attribute()
Hi, I am working with PHP 4.3 on windows. I am using PHP DOM functions to update the XML file. When I try to set the attribute of a particular node, the subsequent get returns the set value, but it doesn't reflect in the memory structure. echo ###,$build_node-get_attribute('path'); = this returns the original path value. $build_node-set_attribute('path', 'new_path'); echo ###,$build_node-get_attribute('path'); = this returns the new_path value. var_dump($build_node); = This does not reflect the change in path attribute for the build_node, it shows the the original path value. Can anybody help me in this issue? Thanks, Jils
[PHP] DOM/XML Query
I'm having some problems using PHP5 on Windows 2000 Server, running IIS 5. When trying to access a document from a xmldoc() function the system responds with the following, *Fatal error*: Call to undefined function xmldoc() in *XML Document* on line *Number* ** How do I fix this problem? Is there a fix for this? Thanks for your help
Re: [PHP] DOM XML compatible PHP4 PHP5
On Monday 12 September 2005 02:08 pm, Florent Monnier wrote: Hi, Is there a way to make dom xml applications compatible PHP4 and PHP5? Thanks You can use the PHP_VERSION predefined constant or the function_exists(string) http://us2.php.net/manual/en/function.function-exists.php What I did was created a Document Object. right now it only works with PHP5 I might add PHP4 support to it later tho when I have more time using this approach unless anyone can think of a better idea. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] DOM XML compatible PHP4 PHP5
Hi, Is there a way to make dom xml applications compatible PHP4 and PHP5? Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] DOM XML issue
Hi! I have installed PHP 5.0.4 on MacOS X 10.3 (Panther). Everything works fine exept DOM XML parser. After using phpinfo it shows (dom section): dom DOM/XML enabled DOM/XML API Version 20031129 libxml Version 2.5.4 HTML Support enabled XPath Support enabled XPointer Support enabled Schema Support enabled RelaxNG Suppor tenabled I'm using function domxml_open_file and get following error: Fatal error: Call to undefined function domxml_open_file() in /Users/Andrew/Sites/portfolio/index.php on line 61 How can I fix this problem? Thank you! == Best Regards Andrew Kachalo http://www.geocities.com/andrew_kachalo/
[PHP] DOM XML/XSL questions
I have a requirement to create an XML file which looks approximately like: ?xml version=1.0 ? ?xml-stylesheet type='text/xsl' href='article.xsl' ? article itemItem Text/item ... /article The file needs to be formatted. I built a dom using the Dom extension, creating a document, adding nodes, and I got a nicely formatted XML file from $dom-saveXML(); The only problem I had, was that I could see no way to add the stylesheet definition to the XML. I'm not sure that a DOM should know anything about stylesheets, but an XML file probably should. I managed to bypass the problem, by loading the dom from a file, with the style sheet and the root element included, and then proceeding to build the dom by adding the extra nodes. This also worked fine, but now the output from $dom-saveXML() is no longer formatted. Here is some sample code: ?php $txt =EOT ?xml version=1.0? ?xml-stylesheet type='text/xsl' href='../../../article.xsl' ? Article xmlns='http://www.example.com/xml' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://www.example.com/test/xml article.xsd' /Article EOT; $dom = new DOMDocument(); $dom-preserveWhiteSpace = FALSE; $dom-resolveExternals = TRUE; $dom-loadXML($txt); $item = $dom-createElement(Item); $itemText = $dom-createTextNode(Item Text); $item-appendChild($itemText); $dom-documentElement-appendChild($item); $dom-formatOutput = TRUE; echo $dom-saveXML(); ? My questions are: 1) How should I add a stylesheet to this type of document? (I do not need to process the stylesheet in php, it is for the guidance of the end user of the document, who may use it or modify it), and, 2) Is this a (dare I say bug in an experimental extension) that if I load the dom, and perform operations on the dom, I lose formatting(A dom that is just loaded, or just created by dom operations, is correctly formatted, a dom with mixed processes is not). TIA for any advice... Dusty -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] DOM XML/XSL questions
On Wed, 27 Oct 2004 13:52:13 +0100, Dusty Bin [EMAIL PROTECTED] wrote: I have a requirement to create an XML file which looks approximately like: ?xml version=1.0 ? ?xml-stylesheet type='text/xsl' href='article.xsl' ? article itemItem Text/item ... /article The file needs to be formatted. I built a dom using the Dom extension, creating a document, adding nodes, and I got a nicely formatted XML file from $dom-saveXML(); The only problem I had, was that I could see no way to add the stylesheet definition to the XML. I'm not sure that a DOM should know anything about stylesheets, but an XML file probably should. I managed to bypass the problem, by loading the dom from a file, with the style sheet and the root element included, and then proceeding to build the dom by adding the extra nodes. This also worked fine, but now the output from $dom-saveXML() is no longer formatted. Here is some sample code: ?php $txt =EOT ?xml version=1.0? ?xml-stylesheet type='text/xsl' href='../../../article.xsl' ? Article xmlns='http://www.example.com/xml' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://www.example.com/test/xml article.xsd' /Article EOT; $dom = new DOMDocument(); $dom-preserveWhiteSpace = FALSE; $dom-resolveExternals = TRUE; $dom-loadXML($txt); $item = $dom-createElement(Item); $itemText = $dom-createTextNode(Item Text); $item-appendChild($itemText); $dom-documentElement-appendChild($item); $dom-formatOutput = TRUE; echo $dom-saveXML(); ? My questions are: 1) How should I add a stylesheet to this type of document? (I do not need to process the stylesheet in php, it is for the guidance of the end user of the document, who may use it or modify it), and, Use $dom-createProcessingInstruction($target, $data) ; and then append this to the document. that could maybe work see http://ch.php.net/manual/en/function.dom-domdocument-createprocessinginstruction.php for more details. 2) Is this a (dare I say bug in an experimental extension) that if I load the dom, and perform operations on the dom, I lose formatting(A dom that is just loaded, or just created by dom operations, is correctly formatted, a dom with mixed processes is not). The extension is not experimental anymore ;) And the formatting is not lost. you didn't provide any ;) The DOM Extension doesn't make any assumptions about the formatting of your XML document (or correctly said, it doesn't insert whitespace automagically ) but you can try to set the property formatOutput just before saveXML: $doc-formatOutput = true; Never tested, but should work chregu TIA for any advice... Dusty -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich phone +41 1 240 56 70 | mobile +41 76 561 88 60 | fax +41 1 240 56 71 http://www.bitflux.ch | [EMAIL PROTECTED] | gnupg-keyid 0x5CE1DECB -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] DOM XML/XSL questions
Christian Stocker wrote: snip /snip Use $dom-createProcessingInstruction($target, $data) ; and then append this to the document. that could maybe work see http://ch.php.net/manual/en/function.dom-domdocument-createprocessinginstruction.php for more details. Thank you Christian, the following code worked fine. (From within the DOM object) $this-preserveWhiteSpace = false; $this-resolveExternals = true; $styleSheet = $this-createProcessingInstruction(xml-stylesheet, type='text/xsl' href='../../../course.xsl'); $this-appendChild($styleSheet); $this-createRoot(); $this-formatOutput = TRUE; snip /snip And the formatting is not lost. you didn't provide any ;) The DOM Extension doesn't make any assumptions about the formatting of your XML document (or correctly said, it doesn't insert whitespace automagically ) but you can try to set the property formatOutput just before saveXML: $doc-formatOutput = true; Never tested, but should work I already had formatOutput = true; in the sample code. Of course when I am loading the DOM from a string, I am providing the formatting, which DOM is honouring but when I am creating the DOM completely from php, you are right, I am providing no formatting. In this case, the formatOutput works as I would have expected, (default??)formatted output when true, and not formatted when false. It would seem that if you provide some formatting, DOM expects you to provide it all. When I have finished this current assignment, I'll try to follow the calls through from PHP to libxml2, and see if I can find something more. Once again, thanks for your help... Dusty -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] DOM XML output whitespace
Hello, Is there a way to get DOM XML to insert human-friendly whitespace between elements created programmatically? I'm using PHP 5 these days, so I guess I'm looking for some way to tell a DomDocument to prettify its save() output. Thanks! -Dan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] DOM XML and php
Hello, I face a problem. I have a php script and I send a xml request to a server. After I receive xml data but I have this data to an php string variable. How to create a xml dom with out to write a xml file ? I want to use a xslt to tranform that xml data. Any idea ? Thanks tassos -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] DOM XML difference between PHP versions 4.2.1 and 4.3.3
Hello I wonder if anyone can help me with this problem or suggest an alternative strategy. I have two PHP boxes, one windows box running PHP version 4.2.1 and DOM XML version 2.4.9, and the other one a FreeBSD box running PHP version 4.3.3 and DOM XML version 2.5.11. What I need to do is to join two XML documents together. The code below runs fine on the 4.2.1 box but fails on the 4.3.3 box. //$pagenodes_doc_xml and $menu_xml have been previously populated with valid XML document objects // get page nodes root element $pagenodes_xml = $pagenodes_doc_xml-document_element(); //locate portalroot in menu xml $ctx = xpath_new_context($menu_xml); $nodes = xpath_eval($ctx, //[EMAIL PROTECTED]'portalroot']); $portalroot = $nodes-nodeset[0]; //append pages nodes at portalroot location $new_xml = $portalroot-append_child($pagenodes_xml); The error is Warning: append_child(): Can't append node, which is in a different document than the parent node. Simon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] DOM XML difference between PHP versions 4.2.1 and 4.3.3
Hi, Friday, October 24, 2003, 9:37:07 PM, you wrote: S Hello S I wonder if anyone can help me with this problem or suggest an alternative S strategy. S I have two PHP boxes, one windows box running PHP version 4.2.1 and DOM XML S version 2.4.9, and the other one a FreeBSD box running PHP version 4.3.3 and S DOM XML version 2.5.11. S What I need to do is to join two XML documents together. The code below S runs fine on the 4.2.1 box but fails on the 4.3.3 box. S //$pagenodes_doc_xml and $menu_xml have been previously populated with S valid XML document objects S // get page nodes root element S $pagenodes_xml = $pagenodes_doc_xml-document_element(); S //locate portalroot in menu xml S $ctx = xpath_new_context($menu_xml); S $nodes = xpath_eval($ctx, //[EMAIL PROTECTED]'portalroot']); S $portalroot = $nodes-nodeset[0]; S //append pages nodes at portalroot location S $new_xml = $portalroot-append_child($pagenodes_xml); S The error is Warning: append_child(): Can't append node, which is in a S different document than the parent node. S Simon I think you have to use clone node $pagenodes_xml = $pagenodes_doc_xml-document_element(); $newnode = $pagenodes_xml-clone_node(1); //don't remember why the 1 :) $ctx = xpath_new_context($menu_xml); $nodes = xpath_eval($ctx, //[EMAIL PROTECTED]'portalroot']); $portalroot = $nodes-nodeset[0]; $new_xml = $portalroot-append_child($newnode); -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP DOM XML Function
do you have any idea about PHP DOM XML functions? when will PHP DOM XML functions be stable? Fatih stnda Yre Elektronik Yaymclk A.. 0 212 234 00 90 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP DOM XML Function
Hello, As far as I know from Christian Stocker (the domxml maintainer) - they are already pretty stable. They are tagged as experimental to avoid people complaints about API changes (API changes are necessary because DOMXML should have a DOM api, and it was pretty not like this at the beggining). However, we are using Krysalis with DOMXML (we have even renounced at Sablotron and we are using only domxml) for dynamic XML/XSL publishing, and the API is pretty stable already (there might be some leaks on windows, but we don't have any real data yet on this). Alexandru -- Alexandru COSTIN Chief Operating Officer http://www.interakt.ro/ +4021 411 2610 Fgôk ÞôündÉö [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] do you have any idea about PHP DOM XML functions? when will PHP DOM XML functions be stable? Fatih Üstündað Yöre Elektronik Yayýmcýlýk A.Þ. 0 212 234 00 90 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] DOM XML : experimental ?
Hi, I am planning to use PHP to develop some scripts that will need to create and manipulate html pages. One of the things that will be created is a DOM tree of the html. After reading the manual I've found that php supports the event-driven and dom xml, but with the latter tagged as EXPERIMENTAL. I've also noticed that as of 4.3.0-dev (which I am using) the api has changed. So I'd like to know how experimental (also stable) this support is and suggestions regarding this issue and DOM itself. One of the main issues is that I'll need to cope with html (not xml) and mostly not well-formed. Regards. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] DOM XML
Hello, I have been recently doing experiments with the DOM XML function and I am (not surprisingly) having some problems with it. When I try to run the code below, I get an error saying I am trying to use and endefined function. To me it seems that the DOM XML extension is working fine, because I get no error from xmldoc(), but I am still not sure what the problem is. I am running PHP 4.2 Code: ?php $str = ?XML version=\1.0\?menameAnyname/name/me; $dom = xmldoc($str); $root = $domxml_root($dom); echo $root-name; ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] DOM XML Issues with 4.1.0?
Hello. I developed a pretty cool website whose content is entirely specified in XML, and use PHP DOM to convert it to HTML (XSL would be a bit painful). Now, with PHP 4.0.6 and libxml2-2.4.7, everything worked fine, except that there was a huge memory leak somewhere in the PHP or the XML DOM code in PHP, and after viewing the website for about 10 minutes, my SuSE linux machine would hang, and my FreeBSD apache server would need to be restarted. So, I tried upgrading to Apache 4.1.0 with libxml2-2.4.12. Unfortunately, a lot doesn't work any more -- when I load in my XML file, I can load it in using xmldocfile(), and I can iterate over the nodes, but none of them have the name property any more. Is there a combination of PHP 4.x and libxml2-2.y that is known to work reasonably well and not leak memory like mad? Thanks! mark. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] DOM XML?
Hello, I would like to restyle one big site in XML and I would like some brief straight info/suggestions. I am definitely interested in DOM XML, but as far as I can understand, the module is still experimental and there to main risks: - The module is not completely stable - The functions are likely to change Are you able to confirm me these? As an alternative, it seems the only safe way to develop XML in PHP is by using the Expat module. Is this your view too? In any case, are you able to indicate some good web references for XML in PHP ? Really thanks for the help. Daniele -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] DOM XML module
Hi I need to use the DOMXML functions on a PHP 4.0.4 (Mandrake 8.0) page, but the module is not there by default. Having downloaded the sources and tried to rebuild from scratch, I get a bunch of new dependency problems. Looks like building a full featured PHP is not that easy,,, So my question is; is there an available domxml.so module somewhere that fits Mandrake 8.0/PHP 4.0.4. I have tried a prebuilt module that I found on rpmfind but that module did not worked since it required 4.0.6 (Polished distribution something). Best regards Anders