phpeveryday.com

The best tutorial of php, php framework, php strategies, object oriented oriented,


PHP - XML: Read from String

Tag: xml, string   Category: PHP Basic
post: 23 Mar 2008 read: 1,076


PHP XML Tips - Part 1: If you have a variable contains XML data, you can read/parse like this:

<?php
$xmlData =<<< END
<?xml version="1.0"?>
<datas>
  <books> 
    <book>
      <id>1</id>
      <title>PHP Undercover</title>     
      <author>Wiwit Siswoutomo</author>
    </book>
  </books>
</datas>
END;

$xml = simplexml_load_string($xmlData) 
       or die("Error: Can not create object");

?>

Yes, we can use simplexml_load_string() function.



Series this article:
PHP - XML: Read from String
PHP - XML: Read from a File
PHP - XML: Retrieving Node Values
PHP - XML: Retrieving Attribute Values
PHP - XML: Processing XML
PHP - XML: Creating XML Document
PHP - XML: Adding XML Nodes
PHP - XML: Removing Node
PHP - XML: Replacing Node
PHP - XML: Filtering XML Nodes with XPath
PHP - XML: Filtering XML Nodes by Namespace

| Give Your Opinion | Recommend
Share and Bookmark to: These icons link to social bookmarking sites where readers can share and discover new web pages.
digg del.icio.us technorati Ma.gnolia BlinkList

Recommended articles by other readers:
Web Services: How PHP Kiss VB.NET? (Part 1)
Joomla: Fast Road to Understand Component Programming
Chart: How to Build Cool Animation Real Time Chart
Email: Send Attachement Mail
SMS : Sending SMS with PHP and ActiveXperts (Part 1)

What do You Think?
Your Name *:
Email *:
(Will not be published)
Website/URL:
Your Comment *:
* Required


624
posting