Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Software Development
Programming
Programming Q&A
How to read XML in PHP
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="griimnak" data-source="post: 450890" data-attributes="member: 35695"><p>I replicated your code, this is what i got:</p><p>[CODE=php]</p><p></p><p><?php</p><p>// set reporting</p><p>error_reporting(E_ALL);</p><p>ini_set('display_errors', 1);</p><p>// test php</p><p>echo "ping";</p><p>// load</p><p>$xmldata = simplexml_load_file("C:\ProgramData\griimnak\Config\Config.xml") or die("Failed to load");</p><p>// This does not work for me **</p><p>echo $xmldata->DatabaseConnection[0]->DataSource;</p><p>echo $xmldata->DatabaseSettings[0]->LicenseKey;</p><p>// **</p><p>// but this does work for me</p><p>echo "\n";</p><p>echo $xmldata->DatabaseConnection[0]["DataSource"];</p><p>echo "\n";</p><p>echo $xmldata->DatabaseConnection[0]["UserID"];</p><p>// raw print confirms it works</p><p>echo "\n";</p><p>print_r($xmldata->DatabaseConnection);</p><p></p><p>[/CODE]</p><p><img src="https://i.imgur.com/2P7DyiV.png" alt="" class="fr-fic fr-dii fr-draggable " style="" /></p><p></p><p>Try changing</p><p>[CODE=php]</p><p>echo $xmldata->DatabaseConnection[0]->DataSource;</p><p>echo $xmldata->DatabaseSettings[0]->LicenseKey;</p><p>[/CODE]</p><p></p><p>To</p><p>[CODE=php]</p><p>echo $xmldata->DatabaseConnection[0]["DataSource"];</p><p>echo $xmldata->DatabaseSettings[0]["LicenseKey"];</p><p>[/CODE]</p></blockquote><p></p>
[QUOTE="griimnak, post: 450890, member: 35695"] I replicated your code, this is what i got: [CODE=php] <?php // set reporting error_reporting(E_ALL); ini_set('display_errors', 1); // test php echo "ping"; // load $xmldata = simplexml_load_file("C:\ProgramData\griimnak\Config\Config.xml") or die("Failed to load"); // This does not work for me ** echo $xmldata->DatabaseConnection[0]->DataSource; echo $xmldata->DatabaseSettings[0]->LicenseKey; // ** // but this does work for me echo "\n"; echo $xmldata->DatabaseConnection[0]["DataSource"]; echo "\n"; echo $xmldata->DatabaseConnection[0]["UserID"]; // raw print confirms it works echo "\n"; print_r($xmldata->DatabaseConnection); [/CODE] [IMG]https://i.imgur.com/2P7DyiV.png[/IMG] Try changing [CODE=php] echo $xmldata->DatabaseConnection[0]->DataSource; echo $xmldata->DatabaseSettings[0]->LicenseKey; [/CODE] To [CODE=php] echo $xmldata->DatabaseConnection[0]["DataSource"]; echo $xmldata->DatabaseSettings[0]["LicenseKey"]; [/CODE] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Software Development
Programming
Programming Q&A
How to read XML in PHP
Top