• Home
  • Advertise
  • Contact Us
  • Free eBooks
  • Infographics
  • About Us


  • Technology
    • Programming
      • Java
      • PHP
      • HTML
      • CSS
      • Javascript
      • XML
      • AJAX
      • JQuery
      • Perl
      • IDE
    • CMS
      • Opencart
      • WordPress
      • Prestashop
      • Magento
    • Database
  • Security
    • Cyber Laws
    • Digital Signature
    • Passwords
    • Reverse Engineering
    • Steganography
    • Forensics
    • Networking
  • E-Commerce
  • Digital Media
    • SEO
    • Social Media
      • Facebook
  • Gadgets
    • Laptops
    • Tablets
    • Just CellPhones
    • Social CellPhones
  • OS
    • Linux
    • Mac
    • Windows
    • iOS
    • Android
  • Courses
    • Development in Android
  • General

Breaking

The supercomputer "Tianhe-2" Takes No. 1 Ranking on 41st TOP500 List

Export tweets in different formats

OWASP - Top 10 Vulnerabilities

New Windows-backdoor deletes MBR

The world's first CPU of 5GHz

Critical vulnerability in 60 + models of CCTV and IP-cameras

Hack a Samsung TV with SmartTV function

The man who "almost broke the Internet"

The search continues for the sixth member of LulzSec

Statistics on the botnet Carna


Load an External XML file in PHP

0 Comment
 11 Jul 2012   Posted by Aals

1 Star2 Stars3 Stars4 Stars5 StarsContent...">
Loading ... Loading ...


flattr this!

You can use simplexml_load_file(string $filename) to this end. Just pass into this function the full URL

$xml->nodename

<nodename code=”603″ name=”somename”><subnode>Content</subnode></nodename>

echo $xml['code'];
echo $xml['name'];
echo $xml->subnode;

If there are more subnodes then :

echo $xml->subnode->subnode2->; //& so on

If you need to fetch from a longer list, like for example you need to retrieve all the Names,RollNos & Age of all Students in a Class then you will you a loop:

XML data :

<Class>
<Student rollno=”101″ age=”14″>Ron D </Student>
<Student rollno=”102″ age=”14″>Mark V </Student>
<Student rollno=”103″ age=”12″>Veronica A </Student>
</Class>

PHP code to load data :

foreach ($xml->Class->Student as $name)
{
echo $name;
echo ” – “.$name['rollno'];
echo ” – “.$name['age'];
echo “<br/>”;
}

 

 

Spread The Word:

  • Facebook
  • Twitter
  • Pinterest
  • StumbleUpon
  • Google +1
  • Digg
  • Reddit
  • Email
  • LinkedIn
  • Tumblr
    Share This


Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

  • Find Us On Facebook

  • Airtel Hello Tunes

  • Ads.

  • Ads.

  • Shrugs Online


  • More...

    • Advertise
    • Crawl Fashion | Fashion Directory
    • Information Technology Act 2000 Compliance [Sec 43A and Sec 72A]
    • Java Tutorial
    • Netbeans Tutorial
    • Photography Blogs
    • Street Shopping
    • Virus Protection And Internet Security
  • Recent Posts

    • Cannot login to Magento Admin Panel after Installation!
    • Magento - PHP Extension "curl" must be loaded
    • W3C published full specification for HTML5
    • Load an External XML file in PHP
    • Oracle has released a beta version of NetBeans 7.2
    • PHP IDE Review : CodeLobster
  • Enter your email address to subscribe to "Bytes" Mag & receive THE latest updates on Tech!


Copyright © LetsByteCode Inc.
DMCA.com
loading Cancel
Post was not sent - check your email addresses!
Email check failed, please try again
Sorry, your blog cannot share posts by email.