473,698 Members | 2,632 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

So lost, xml, php, arrays help pls!

I am totally lost.

I have an xml script example as follows:

<?xml version="1.0" encoding="utf8" ?>
<starter>
<second>
<name>Silver</name>
</second>
</starter>

I have this printing to an array with the following php code:

class RSSParser {

var $struct = array(); // holds final structure
var $curptr; // current branch on $struct
var $parents = array(); // parent branches of current branch

function RSSParser($url) {
$this->curptr =& $this->struct; // set ref to base
$xmlparser = xml_parser_crea te();
xml_set_object( $xmlparser, $this);
xml_set_element _handler($xmlpa rser, 'tag_open', 'tag_close');
xml_set_charact er_data_handler ($xmlparser, 'cdata');
$fp = fopen($url, 'r');

while ($data = fread($fp, 4096))
xml_parse($xmlp arser, $data, feof($fp))
|| die(sprintf("XM L error: %s at line %d",
xml_error_strin g(xml_get_error _code($xmlparse r)),
xml_get_current _line_number($x mlparser)));

fclose($fp);
xml_parser_free ($xmlparser);
}

function tag_open($parse r, $tag, $attr) {
$i = count($this->curptr['children']);
$j = count($this->parents);
$this->curptr['children'][$i]=array(); // add new child element
$this->parents[$j] =& $this->curptr; // store current position as
parent
$this->curptr =& $this->curptr['children'][$i]; // submerge to
newly created child element
$this->curptr['name'] = $tag;
if (count($attr)>0 ) $this->curptr['attr'] = $attr;
}

function tag_close($pars er, $tag) {
$i = count($this->parents);
if ($i>0) $this->curptr =& $this->parents[$i-1]; // return to
parent element
unset($this->parents[$i-1]); // clear from list of parents
}

function cdata($parser, $data) {
$data = trim($data);
if (!empty($data)) {
$this->curptr['value'] .= $data;
}
}

}

$myparser = new RSSParser('Cred itCardBank.xml' );

echo "<pre>";
$results = ($myparser->struct);
print_r($result s);

-----

I get the following array:

[1] => Array
(
[name] => STARTER
[children] => Array
(
[0] => Array
(
[name] => NAME
[value] => Silver
Person&
)

)

)

-------

I need to be able to take the above array results and use them to
populate a menu, yet at the same time create ANOTHER array that
cleanses the : [value] => Silver Person& to remove the capitol
letters, spaces and charachters other than hyphens, letters and
numbers. I need the new array to show something like Silver Person& ==>
SilverPerson

Is this EVEN possible??

Jun 14 '06 #1
0 1069

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1462
by: millw0rm | last post by:
Hi, here is the complete detail what i m trying 2 do. i got around 2000+ images with size/desp/image_no/slno etc TABLE `sheet1` ( `SlNo` int(11) NOT NULL auto_increment, `Image No` double default NULL, `Title` varchar(255) default NULL, `Category` varchar(255) default NULL,
35
3664
by: Troll | last post by:
Hi, I need to write a script which reads some data and reports the findings. Just to give you an idea the structure is similar to the following. Data input example: HEADING 1 ********** ColumnA ColumnB ColumnC ColumnD ColumnE
0
2080
by: Al Caponi | last post by:
Hi all, There is a limitation on Win98 when a client app using mm.mysql driver doing extensive queries to MySQL 3.23.x frequently encounters a connection lost error. Error msg is something like: 'java.lang.Exception: Cannot connect to MySQL server on localhost:3306. Is there a MySQL server running on the machine/port you are trying to connect to? (java.net.SocketException)'
27
2967
by: jacob navia | last post by:
Has anyone here any information about how arrays can be formatted with printf? I mean something besides the usual formatting of each element in a loop. I remember that Trio printf had some extensions but I do not recall exactly if they were meant for arrays. Thanks
2
1388
by: Raghu Raman | last post by:
Hi, In javascript file i store 3 values under a single cookie array ,like var myarray = new Array(null); myarray = "field_1"; myarray = "field_2"; myarray = "field_3"; document.cookie ="myarray=" + myarray;
3
2015
by: c++dummy | last post by:
I got this project for my class and I'm totally lost as to how to copy the 1d array with the bone name into a 2d array using this supposed strncpy function I'm supposed to create. I believe the teacher wants us to make the function and not use the library function. Here's the info: Write a C++ program that
9
1266
by: jyohere | last post by:
Can anyone explain in detail why arrays are implemented as objects in java.And wat do we mean by arrays of arrays in java.....am not getting it completely....how does arrays differ from other languages when we use a 2d array for example.pls explain with example how a 2d array will be stored in memory.I studied Baldwin's array tutorials....it was good...but there was no diagram to explain how they are stored in memory.....am looking out for a...
6
1365
by: annerhexian | last post by:
hi.. pls help me... im just new in php and i wish i could learn more.. i needed it for one day or two..hope u can reconsider my questions to you.. pls do help me.. i want my row array will be a column..... pls see me first my codes: DATAbase:
2
5833
by: kenrocks | last post by:
well my problem is that I can 't figure how to arrange strings in arrays in an alphabetical order. pls.. answer asap..thx..:)
0
9171
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9032
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8905
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8880
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6532
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5869
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4373
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.