answersLogoWhite

0

Here is an example of how you can grab some information from an xml file using the XMLReader php class.

<?xml version="1.0" encoding="utf-8"?>

<users>

<row Id="1" UserName="Paul" />

<row Id="2" UserName="Dave" />

<row Id="3" UserName="Fred" />

</users>

Here is the code to read and grab the information:

<?php

// load up the xml reader class

$reader = new XMLReader();

// xml file to open and read

$reader->open('<url to xml file>');

// loop through the results

while ($reader->read()) {

$id = trim($reader->getAttribute('Id')); // grab the id

$username = trim($reader->getAttribute('UserName')); // grab the username

echo "{$id} > {$username}<br />"; // echo the results

}

// close the xml file

$reader->close();

?>

User Avatar

Wiki User

15y ago

What else can I help you with?

Related Questions

What is the use of a question mark in php?

It is used to tell the sever to use the PHP parser. To begin php you must use &lt;?php, and to end it, it is ?&gt;.


How do you use PHP in HTML?

You can't use PHP in an HTML document, but you can use HTML in PHP script.


PHP case sensitivity refers to what?

PHP case sensitivity refers to that in coding it matters if the code is in capital letters. Case sensitivity specifically in PHP refers to variables, constants, array keys, class properties, and class constants. Some items in PHP that are not case sensitive are functions, class constructors, class methods, and keywords and constructs.


Why should you use PHP and not JSP?

Firstly, this is wrong question. The right one would be WHEN should you use PHP, not JSP? or, WHEN should you use PHP and WHEN JSP?


What is the present social status of the Philippines?

The Philippines, is 12% Class ABC, 49% D and 39% E as of April 2010. Class A - Upper Class - executives, presidents, CEOs (&gt;Php 100,000 / month) Class B - Upper Middle Class - professionals (Php 50,000-100,000 / month) Class C - Middle Class - white-collar jobs (Php 15,000-50,000 / month) Class D - Lower Middle Class - blue-collar/clerical jobs (Php,8,000-15,000 / month) Class E - Lower Class - living below the poverty line (&lt;Php 8,000 / month)


How do you use XML in PHP?

PHP 5 has a XML parser called SimpleXML that you could use.


How do you create a web mail script using PHP?

You can use phpMailer() Or, you can use mail() PHP function to send emails via PHP script.


What is a PHP certificate?

PHP certification is received after doing some sort of PHP course, there are many out there to do. You can use them in your CV to help you get a job in PHP.


Where could one find information about how to use PHP 5?

You can find information about how to use PHP 5 on the official PHP website, PHP.net, through the PHP 5 documentation section. Additionally, online tutorials, forums, and books dedicated to PHP programming are great resources to learn how to use PHP 5 effectively.


Which PHP version does Facebook use?

Facebook uses PHP 5.


How do you center a container in php?

You do not center any HTML constructs inside PHP itself. First of all its bad practice to mix php code with HTML, for that you can use a template engine like smarty. Next, in case you DO want to mix HTML and PHP, then simply give the "container" element an ID or a class name. This one then can be styled via CSS.


What are the PHP tags?

There are no PHP tags. Unlike HTML, PHP is not Markup language. They use scripts. An example would be &lt;?php echo "Hello, World!"; ?&gt;