This site is mobile accessible. Press the "Tap Here" button to use a different font-size.


Smartphone icons created by Freepik - Flaticon

PHP SimpleXML - Get

Get Node Values - Loop (test menu [9])

1.1 PHP Intro 1.2 PHP Install 1.3 PHP Syntax 1.4 PHP Comments 1.5 PHP Variables 1.5.1 Variables Scope 1.6 PHP Echo / Print 2.1 PHP Data Types 2.2 PHP Strings 2.3 PHP Numbers 2.4 PHP Math 2.5 PHP Constants 3.1 PHP Operators 3.2 PHP If Else Elseif 3.3 PHP Switch 3.4 PHP Loops 3.4.1 While Loop 3.4.2 Do While Loop 3.4.3 For Loop 3.4.4 Foreach Loop 3.4.5 Break/Continue 3.5 PHP Functions 4.1 PHP Arrays 4.1.1 Indexed Arrays 4.1.2 Associative Arrays 4.1.3 Multidimensional Arrays 4.1.4 Sorting Arrays 4.2 PHP Superglobals 4.2.1 $GLOBALS 4.2.2 $_SERVER 4.2.3 $_REQUEST 4.2.4 $_POST 4.2.5 $_GET 4.3 PHP RegEx 5.1 PHP Form Handling 5.2 PHP Form Validation 5.3 PHP Form Required 5.4 PHP Form URL / E-mail 5.5 PHP Form Complete 6.1 PHP Date and Time 6.2 PHP Include Files 6.3 PHP File Handling 6.4 PHP File Open/Read 6.5 PHP File Create/Write 6.6 PHP File Upload 6.7 PHP Cookies 6.8 PHP Sessions 6.9 PHP Filters 6.10 PHP Filters Advanced 6.11 PHP Callback Functions 6.12 PHP JSON 6.13 PHP Exceptions 7.1 PHP What is OOP 7.2 PHP Classes / Objects 7.3 PHP Constructor 7.4 PHP Destructor 7.5 PHP Access Modifiers 7.6 PHP Inheritance 7.7 PHP Class Constants 7.8 PHP Abstract Classes 7.9 PHP Interfaces 7.10 PHP Traits 7.11 PHP Static Methods 7.12 PHP Static Properties 7.13 PHP Namespaces 7.14 PHP Iterables PHP course home 8.1 MySQL Database 8.2 MySQL Connect 8.3 MySQL Create DB 8.4 MySQL Create Table 8.5 MySQL Insert Data 8.6 MySQL Get Last ID 8.7 MySQL Insert Multiple 8.8 MySQL Prepared 8.9 MySQL Select Data 8.10 MySQL Where 8.11 MySQL Order By 8.12 MySQL Delete Data 8.13 MySQL Update Data 8.14 MySQL Limit Data 9.1 PHP XML Parsers 9.2 PHP SimpleXML Parser 9.3 PHP SimpleXML - Get 9.4 PHP XML Expat 9.5 PHP XML DOM 10.1 AJAX Intro 10.2 AJAX PHP 10.3 AJAX Database 10.4 AJAX XML 10.5 AJAX Live Search 10.6 AJAX Poll My Poll
// contents of external file
    <URL>
        <title>PHP Course Menu</title>
        <link>
            class='navigate' href='.'
        </link>
    </URL>
    <URL>
        <title>9.1 PHP XML Parsers</title>
        <link>
            class='navigate' href='9-1PHPXMLParsers.php'
        </link>
    </URL>
    <URL>
        <title>9.2 PHP SimpleXML Parser</title>
        <link>
            class='navigate' href='9-2PHPSimpleXMLParser.php'
        </link>
    </URL>
    <URL>
        <title>9.3 PHP SimpleXML - Get</title>
        <link>
            class='navigate' href='9-3PHPSimpleXMLGet.php'
        </link>
    </URL>
    <URL>
        <title>9.4 PHP SimpleXML</title>
        <link>
            class='navigate' href=''
        </link>
    </URL>
    <URL>
        <title>9.5 PHP SimpleXML</title>
        <link>
            class='navigate' href='.'
        </link>
    </URL>


// load external file, extract and display the desired data
<?php
$xml=simplexml_load_file("include/testmenu.xml") or die("Error: Cannot create object");
foreach($xml->children() as $URL) {
        echo "<a " . $URL->link . ">" . $URL->title . "</a> ";
}
?>