Current location: Hot Scripts Forums » Programming Languages » PHP » Can I do this with php?


Can I do this with php?

Reply
  #1 (permalink)  
Old 06-25-05, 04:44 PM
getwithrob getwithrob is offline
Newbie Coder
 
Join Date: Apr 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Can I do this with php?

I would like to be able to search a large xml file from a browser and display the results in the same browser. Can someone direct me to snippets to point somewhere to get me started.

This is one section of xml code that is repeated several thousand times. I would like to be able to enter a MAC or IP to search the file against and return the information in that section of the file to the browser.

<UTData>
<Index>15030590</Index>
<UserName/>
<MACAddress>00-0d-56-9e-ad-f9</MACAddress>
<HostName>csimpam349142.impl.ca.kp.org</HostName>
<IPAddress>10.202.71.27</IPAddress>
<Subnet>10.202.70.0</Subnet>
<DeviceName>lcaimpc115-d3105.impl.ca.kp.org</DeviceName>
<Device>10.202.62.115</Device>
<Port>Fa0/2</Port>
<PortName>KPHC Reserved</PortName>
<PortState>static</PortState>
<VTPDomain>caimp</VTPDomain>
<VLAN>10.202.70.0/23</VLAN>
<VLANType>ethernet</VLANType>
<Ring/>
<Bridge/>
<trBRFVLAN/>
<LastSeen>2005/05/19 05:27:31</LastSeen>
<Notes/>
<PortDuplex>half-duplex</PortDuplex>
<PortSpeed>10M</PortSpeed>
<VLANId>70</VLANId>
</UTData>
Reply With Quote
  #2 (permalink)  
Old 06-26-05, 02:32 AM
NeverMind's Avatar
NeverMind NeverMind is offline
Community VIP
 
Join Date: Aug 2003
Location: K.S.A
Posts: 2,257
Thanks: 0
Thanked 2 Times in 1 Post
if you are using PHP5, you can use SimpleXML lib and simply have something like this:
PHP Code:

$xmlstr file_get_contents('xmlfile.xml');

$xml simplexml_load_string($xmlstr);

foreach (
$xml->UTData as $data) {
   if ((string) 
$data->MACAddress == $submited_MAC || (string) $data->IPAddress == $submited_IP)
       
//do whatever you want here
       
print_r($data);

where xmlfile.xml is the file containing XML data..
and you should also have a root element..
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9]
Reply With Quote
  #3 (permalink)  
Old 06-26-05, 10:59 AM
getwithrob getwithrob is offline
Newbie Coder
 
Join Date: Apr 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Thank you for the quick response...

Hopefully I have php 5. I will try this when I get to work tomorrow.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
2 profitable script sites for sale cms-master.com General Advertisements 3 07-03-07 10:17 AM
PHP Downside--Solutions? Amulet PHP 10 07-15-05 08:26 AM
PHP multi-dimensional array sorting issue aqw PHP 2 06-24-05 11:09 PM
PHP / Graphic Developers someotherguy582 Job Offers & Assistance 1 06-05-05 07:40 PM
100 Web Templates & 10 PHP Scripts for sale! HostersUK.co.uk General Advertisements 0 01-10-04 12:31 AM


All times are GMT -5. The time now is 06:51 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.