Home > Archive > PHP Pear > October 2005 > Problem with XML_Serializer
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Problem with XML_Serializer
|
|
| John Malone 2005-10-26, 6:57 pm |
| I'm kind of new to this XML stuff, and I've been trying to implement the XML
Serializer to unserialize a toolbar configuration like the following:
<?xml version="1.0" encoding="utf-8"?>
<TOOLBAR icons="nav.bmp" hot_icons="nav.bmp" name="Google Toolbar"
dllname="google_toolbar" id="tbs_toolbar_007370">
<BUTTON caption="" hint="My Logo" id="tb_btn_vFSMgLLx" img=""
command="redirect" href="http://www.google.com">
<MENU type="Split" img="demo_logo.bmp" hotimg="demo_logo.bmp"
id="tbs_menu_011299">
<ITEM caption="Google Home Page" hint="Navigate to the Google home page"
img="" href="http://www.google.com" command="redirect"
id="tbs_item_011508"/>
<ITEM caption="Google Links" hint="" img="" id="tbs_item_016659">
</MENU>
</BUTTON>
<SEPARATOR id="tbs_separator_000555"/>
<COMBO name="search" caption="" hint="Search Google" limit="40" histmax="10"
id="tb_cmb_SVCgVyWG" command="keMdXGRo" dwidth="130" kind="editable">
</COMBO>
<BUTTON caption="Search Web" hint="Search the Web" id="tb_btn_LKRIuoCj"
img="93" command="OGFnfNCz">
<MENU type="Split" img="" hotimg="" id="tbs_menu_019589">
<ITEM caption="Search Web" hint="" img="" command="pXyPVctx"
id="tbs_item_003161"/>
</MENU>
</BUTTON>
</TOOLBAR>
The problem I am running into is that the order of the elements is important
to me, because this format determines how my toolbar will look. When I run
it through the unserializer, each button gets put into button[] and each
combo gets put into combo[] and my order is lost. What I'm looking to do is
have the elements brought into a toolbar[] and then I can check if button[]
is set for toolbar[0] or if combo is set for toolbar[0].
Any suggestions?
Thank you in advance,
John
| |
| Greg Beaver 2005-10-26, 6:57 pm |
| John Malone wrote:
> I'm kind of new to this XML stuff, and I've been trying to implement the XML
> Serializer to unserialize a toolbar configuration like the following:
>
> <?xml version="1.0" encoding="utf-8"?>
> <TOOLBAR icons="nav.bmp" hot_icons="nav.bmp" name="Google Toolbar"
> dllname="google_toolbar" id="tbs_toolbar_007370">
> <BUTTON caption="" hint="My Logo" id="tb_btn_vFSMgLLx" img=""
> command="redirect" href="http://www.google.com">
> <MENU type="Split" img="demo_logo.bmp" hotimg="demo_logo.bmp"
> id="tbs_menu_011299">
> <ITEM caption="Google Home Page" hint="Navigate to the Google home page"
> img="" href="http://www.google.com" command="redirect"
> id="tbs_item_011508"/>
> <ITEM caption="Google Links" hint="" img="" id="tbs_item_016659">
> </MENU>
> </BUTTON>
> <SEPARATOR id="tbs_separator_000555"/>
> <COMBO name="search" caption="" hint="Search Google" limit="40" histmax="10"
> id="tb_cmb_SVCgVyWG" command="keMdXGRo" dwidth="130" kind="editable">
> </COMBO>
> <BUTTON caption="Search Web" hint="Search the Web" id="tb_btn_LKRIuoCj"
> img="93" command="OGFnfNCz">
> <MENU type="Split" img="" hotimg="" id="tbs_menu_019589">
> <ITEM caption="Search Web" hint="" img="" command="pXyPVctx"
> id="tbs_item_003161"/>
> </MENU>
> </BUTTON>
> </TOOLBAR>
>
> The problem I am running into is that the order of the elements is important
> to me, because this format determines how my toolbar will look. When I run
> it through the unserializer, each button gets put into button[] and each
> combo gets put into combo[] and my order is lost. What I'm looking to do is
> have the elements brought into a toolbar[] and then I can check if button[]
> is set for toolbar[0] or if combo is set for toolbar[0].
>
> Any suggestions?
XML_Serializer will not work for you, you'll have to use a DOM-like
solution, or perhaps simplexml. These all require PHP 5. However, you
can use the unmaintained domxml extension for PHP 4, if PHP 5 is not an
option.
You could also implement your own XML_Parser-based solution, which is a
bit more work. See http://pear.php.net/XML_Parser
Greg
| |
| Luke Barker 2005-10-31, 6:59 pm |
| I can suggest aslo that you could use minixml - google it..a handy set
of classes for manipulating XML in php 4 and 5, as we ll as perl IIRC
--
~L~
lukebarker@gmail.com
---------------------------------------
I'm doggone gonna be with
Some real people...
( Rodgers & Edwards )
|
|
|
|
|