PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old January 8th, 2004, 07:35 PM
aron aron is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: brisbane
Posts: 42 aron User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 9 m 35 sec
Reputation Power: 5
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);

Reply With Quote
  #2  
Old January 8th, 2004, 11:11 PM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
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 =)

Reply With Quote
  #3  
Old January 8th, 2004, 11:24 PM
aron aron is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: brisbane
Posts: 42 aron User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 9 m 35 sec
Reputation Power: 5
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.

Reply With Quote
  #4  
Old January 8th, 2004, 11:27 PM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
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\"> ");

Reply With Quote
  #5  
Old January 8th, 2004, 11:38 PM
aron aron is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: brisbane
Posts: 42 aron User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 9 m 35 sec
Reputation Power: 5
YESSSSSS it workes. thanks mate. (i need to run it through a validator now)

thanks for all your help.

aron.

Reply With Quote
  #6  
Old January 8th, 2004, 11:43 PM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
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?

Reply With Quote
  #7  
Old January 8th, 2004, 11:53 PM
aron aron is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: brisbane
Posts: 42 aron User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 9 m 35 sec
Reputation Power: 5
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

Reply With Quote
  #8  
Old January 9th, 2004, 12:38 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 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

Reply With Quote
  #9  
Old January 9th, 2004, 12:42 AM
aron aron is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: brisbane
Posts: 42 aron User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 9 m 35 sec
Reputation Power: 5
no probs. thanks for your help. it valadated 100% ok.

Reply With Quote
  #10  
Old January 20th, 2004, 12:11 PM
hai mame hai mame is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 8 hai mame User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Angry still have the same problem

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

Reply With Quote
  #11  
Old January 20th, 2004, 12:35 PM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
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.

Reply With Quote
  #12  
Old January 20th, 2004, 12:46 PM
hai mame hai mame is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 8 hai mame User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #13  
Old January 20th, 2004, 12:49 PM
hai mame hai mame is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 8 hai mame User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #14  
Old January 20th, 2004, 01:04 PM
nicat23's Avatar
nicat23 nicat23 is offline
Addicted to Chaos..
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jan 2003
Location: Ft. Worth, TX
Posts: 653 nicat23 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 47 m 52 sec
Reputation Power: 0
Send a message via AIM to nicat23 Send a message via Yahoo to nicat23
Quote:
Originally posted by hai mame
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


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

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > PHP/XML fwrite doctype question.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |