using jqmPhp and XML

79 views
Skip to first unread message

stursby

unread,
Feb 28, 2011, 6:49:16 PM2/28/11
to jqmPhp
Hello,

I was wondering if there's an easy way to integrate and XML list and
jqmPhp.

So far, I've already made a text XML file and then parse it in my
index.php file.

My question is there a way to use the jqmPhp nested list feature to
create the nested lists from my XML file?

Here's my code so far: http://cl.ly/4tnw

Thanks in advance.

_charlie

Bruno Maia

unread,
Mar 1, 2011, 7:26:03 AM3/1/11
to jqm...@googlegroups.com
Hi,

You can use this code to replace your:

<?php
include 'lib/jqmPhp.php';
$j = new jqmPhp();
$p = $j->addPage(new jqmPage('xml-list'), true);
$lv = $p->addContent(new jqmListviem(), true);
$lv->filter(true);
$xml = @simplexml_load_file('list.xml') or die ("no file loaded") ;
$p->header()->title($xml->listName);
foreach ($xml->contact as $contact) {
$lv->addDivider($contact->groupName);
  foreach ($contact->person as $person) {
$lv->addBasic($person->first. " " .$person->last, $person->hash);
  }
}
echo $j;
?>

Regards,

Bruno Maia
xml-list.php
list.xml
index.php

stursby

unread,
Mar 3, 2011, 11:09:52 AM3/3/11
to jqmPhp
@Bruno

Sweet! this is a lot cleaner and simpler code to get the same result.

What I'm trying to do next, is once a person is clicked, load the
following in a new page: Name, Home, Desk, iPhone, Email, and SMS -
from the XML file

Is there an easy way to do this?

Thanks again,

_charlie

On Mar 1, 6:26 am, Bruno Maia <brunoleaom...@gmail.com> wrote:
> Hi,
>
> You can use this code to replace your:
>
> <?php
> include 'lib/jqmPhp.php';
> $j = new jqmPhp();
> $p = $j->addPage(new jqmPage('xml-list'), true);
> $lv = $p->addContent(new jqmListviem(), true);
> $lv->filter(true);
> $xml = @simplexml_load_file('list.xml') or die ("no file loaded") ;
> $p->header()->title($xml->listName);
> foreach ($xml->contact as $contact) {
> $lv->addDivider($contact->groupName);
>   foreach ($contact->person as $person) {
> $lv->addBasic($person->first. " " .$person->last, $person->hash);
>   }}
>
> echo $j;
> ?>
>
> Regards,
>
> Bruno Maia
>
> Em Seg, 2011-02-28 �s 15:49 -0800, stursby escreveu:
>
>
>
>
>
>
>
> > Hello,
>
> > I was wondering if there's an easy way to integrate and XML list and
> > jqmPhp.
>
> > So far, I've already made a text XML file and then parse it in my
> > index.php file.
>
> > My question is there a way to use the jqmPhp nested list feature to
> > create the nested lists from my XML file?
>
> > Here's my code so far:http://cl.ly/4tnw
>
> > Thanks in advance.
>
> > _charlie
>
>
>
>  xml-list.php
> < 1KViewDownload
>
>  list.xml
> 1KViewDownload
>
>  index.php
> 1KViewDownload
Reply all
Reply to author
Forward
0 new messages