PHP DOM

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
d1223m
Forum Commoner
Posts: 80
Joined: Mon Mar 31, 2003 5:15 am
Location: UK, West Sussex

PHP DOM

Post by d1223m »

has anyone written anything to save back from php objects?

the manual describes functions to read it in but say this is to be considered read only.

if not has anyone ideas on creating such a thing?
User avatar
BDKR
DevNet Resident
Posts: 1207
Joined: Sat Jun 08, 2002 1:24 pm
Location: Florida
Contact:

Re: PHP DOM

Post by BDKR »

d1223m wrote: the manual describes functions to read it in but say this is to be considered read only.
Which part of the manual is it that says this? Based on the description of the unserialize function, it's possible to overcome possible issues relating to unserializing objects with the help of the unserialize_callback_func directive.

Check out these links for more data.

http://www.php.net/manual/en/function.unserialize.php
http://www.php.net/manual/en/language.o ... zation.php

This link here may be of some help as well.
http://www.webkreator.com/php/configura ... ading.html

Do some reading and experimenting. You'll get it!
:wink:

Cheers,
BDKR
User avatar
Stoker
Forum Regular
Posts: 782
Joined: Thu Jan 23, 2003 9:45 pm
Location: SWNY
Contact:

Post by Stoker »

since PHP4 doesnt offer any object protection or strict-to-class-def stuff you can generate all variables from the outside...
User avatar
d1223m
Forum Commoner
Posts: 80
Joined: Mon Mar 31, 2003 5:15 am
Location: UK, West Sussex

Post by d1223m »

stoker i dont understand what you mean
User avatar
d1223m
Forum Commoner
Posts: 80
Joined: Mon Mar 31, 2003 5:15 am
Location: UK, West Sussex

Post by d1223m »

BDKR:

the "read-only" thing i was talking about is from http://www.php.net/manual/en/ref.domxml.php
The extension allows you to operate on an XML document with the DOM API. It also provides a function domxml_xmltree() to turn the complete XML document into a tree of PHP objects. Currently, this tree should be considered read-only — you can modify it, but this would not make any sense since DomDocument_dump_mem() cannot be applied to it. Therefore, if you want to read an XML file and write a modified version, use DomDocument_create_element()
Im looking for opposite to xmltree, ie to turn a object tree into an xml file [/quote]
User avatar
Stoker
Forum Regular
Posts: 782
Joined: Thu Jan 23, 2003 9:45 pm
Location: SWNY
Contact:

Post by Stoker »

ah sorry, I think we both missunderstood, sort of forgot about the subject and was thinkiong of PHP-objects only :oops:

hmm yes you are right, PHP-DOM is not superuseful, I did one project ones that would run thru each element and write them on the fly, but was fairly ineffecient, might as well just use arrays instead of DOM..
User avatar
Stoker
Forum Regular
Posts: 782
Joined: Thu Jan 23, 2003 9:45 pm
Location: SWNY
Contact:

Post by Stoker »

BTW, if you don't need it converted back to DOM, you just need the object tree stored you can use serialize for that... and unserialize for reading it back (from file, database or http-post etc).
User avatar
d1223m
Forum Commoner
Posts: 80
Joined: Mon Mar 31, 2003 5:15 am
Location: UK, West Sussex

Post by d1223m »

lol - thats what BDKR said
User avatar
BDKR
DevNet Resident
Posts: 1207
Joined: Sat Jun 08, 2002 1:24 pm
Location: Florida
Contact:

Post by BDKR »

d1223m wrote:lol - thats what BDKR said
Well, one way or the other, it seems that I mis-understood the original post. 8O

Hope you get if figured though.

Cheers,
BDKR
User avatar
d1223m
Forum Commoner
Posts: 80
Joined: Mon Mar 31, 2003 5:15 am
Location: UK, West Sussex

Post by d1223m »

ive been having fun looking thru the pear manual today.

here is pretty much what i wanted :
http://pear.php.net/manual/en/packages.xml.xml_tree.php
Post Reply