|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
PHP/XML fwrite doctype question.
how do i write a doctype in php.
this writes the xml version $doc = new_xmldoc('1.0'); how do i write this. <?xml version="1.0" standalone="no"?> <!DOCTYPE propertyList SYSTEM "http://mywebsite.au/propertyList.dtd"> thyis is basicly how im building my xml file. $doc = new_xmldoc('1.0'); $PropertyList = $doc->add_root("propertyList"); $PropertyList->set_attribute("date", "$tday"); $PropertyList->set_attribute("username", "nuvo"); $PropertyList->set_attribute("password", "xml4a11"); $fp = @fopen('xml/members.xml','w'); if(!$fp) { die('Error cannot create XML file'); } fwrite($fp,$doc->dumpmem()); fclose($fp); |
|
#2
|
||||
|
||||
|
Just as a note, add_root() is deprecated and may not live to see future builds of PHP... here's an example posted on the documentation notes that creates a root without the function:
Code:
$new_dom = domxml_new_doc("1.0");
$new_element = $newdom->create_element("root_el");
$new_node = $newdom->append_child($new_element);
Also, reading the DOM XML functions a couple times, I don't think there's a function to create the doctype automatically... there's functions that will return the doctype information, but can't see any that creates it... Have a look for yourself, maybe my eyes are too tired =) http://www.php.net/manual/en/ref.domxml.php The documentation does make mention of a DomDocument_doctype() but there's no information about it I wasn't able to test this, seems my build doesn't contain the dom functions... Was there anything special you had to do? This really intrigues me and i want to help =) |
|
#3
|
|||
|
|||
|
i changed it to this.
$dom = domxml_open_mem("<?xml version=\"1.0\" standalone=\"no\"?><?xml version=\"1.0\" standalone=\"no\"?>"); $PropertyList = $dom->add_root("propertyList"); $PropertyList->set_attribute("date", "$tday"); $PropertyList->set_attribute("username", "nuvo"); $PropertyList->set_attribute("password", "xml4a11"); $residential = $PropertyList->new_child("residential", ""); $residential->set_attribute("modTime", "$tday"); $residential->set_attribute("status", "status1"); now it writes the standalone="no" correctly now just need it to write the doctype. <!DOCTYPE propertyList SYSTEM "http://mywebsite.au/propertyList.dtd"> i dunno if it makes it any easer. tell me what other information you need. aron. |
|
#4
|
||||
|
||||
|
What would happen if you were to do:
$dom = domxml_open_mem("<?xml version=\"1.0\" standalone=\"no\"?><?xml version=\"1.0\" standalone=\"no\"?>\n\n<!DOCTYPE propertyList SYSTEM \"http://mywebsite.au/propertyList.dtd\"> "); |
|
#5
|
|||
|
|||
|
YESSSSSS it workes. thanks mate. (i need to run it through a validator now)
thanks for all your help. aron. |
|
#6
|
||||
|
||||
|
Always glad to help
For my own personal fetishes, what version of PHP are you running... and did you ahve to enable anything special to get the DOMXML functions to work? |
|
#7
|
|||
|
|||
|
yes i had to get the isp to setup domxml for me.
the isp is running php 4.3.4 http://www.brisbanerealestate.com.au/phpinfo.php cheers aron |
|
#8
|
||||
|
||||
|
Thanks, I found the line in my php.ini file.
I assume uncommenting extension=php_domxml.dll would enable it... Thanks again... Good luck with DOM |
|
#9
|
|||
|
|||
|
no probs. thanks for your help. it valadated 100% ok.
|
|
#10
|
|||
|
|||
|
hi,
i have the same problem stil. I uncommeted the line extension=php_domxml.dll in php.ini file. my phpinfo() also tells that domxml is enabled. But when i tried to run the code 'domxml_open_file()' it shows the following error: Fatal error: Call to undefined function: domxml_open_file() plzz help me to sort out this problem... hai mame |
|
#11
|
||||
|
||||
|
hai mame, you reported this post to the moderators. Reporting a post to the moderators should only be done if the post in question is rude, abusive, etc. One should not report posts to the moderator simply to get answers to their questions.
That said, I imagine this is a PHP version issue. This function is valid only in >= PHP 4.2.1. |
|
#12
|
|||
|
|||
|
sorry i am a new user
hi,
i am using php4.1.1 version. What should i do inorder to use dom concept. I must use advanced version of php 4.2 or i can use this function by making any other alterations...please reply... bye |
|
#13
|
|||
|
|||
|
hi,
i am using php4.1.1 version. What should i do inorder to use dom concept. I must use advanced version of php 4.2 or i can use this function by making any other alterations...please reply... bye |
|
#14
|
||||
|
||||
|
Quote:
Please read the PHP manual for the requirements for using domxml at this address . It will show you what you must have in order to get it to work. PHP 4.1.1 will not support domxml, as dhouston stated.. You will need to uprade php and possibly any other item listed in that link that you don't have up to par. Thanks ![]() |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > PHP/XML fwrite doctype question. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|