Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read SiteMap

Tags: , , , , ,

Sponsored Links



How to use XML DOM in PHP?

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 23-02-2010
Member
 
Join Date: Apr 2009
Posts: 428
How to use XML DOM in PHP?

Hi friends,
I am new to DOM term. I am not having much knowledge about the XML DOM.!! So thought that you guys would help me a bit. Please explain me how to use XML DOM in PHP? Any other information related to the topic would be grateful. Please help me as soon as possible.
Reply With Quote
  #2  
Old 23-02-2010
MELTRONICS's Avatar
Member
 
Join Date: Aug 2006
Posts: 226
Re: How to use XML DOM in PHP?

Before moving to the XML DOM, I recommend you to know about the DOM. The DOM provides a standard set of objects for HTML and XML documents, and a standard interface for accessing and manipulating them. DOM is separated into three different parts which are described as follows :
  1. Core DOM - This part defines a standard set of objects for any structured document.
  2. XML DOM - This part defines a standard set of objects for XML documents.
  3. HTML DOM - This part defines a standard set of objects for HTML documents.
__________________
3.2 (northwood)
2gig ram
ATI AIW X800xt 256mb
Gigabyte GA-8knxp 875p Chipset
Optiwrite 8X DVD Burner
Win XP PRO Sp2 (Works Perfectly)
2 SATA Raptor 74gig Raid 0
2 7200 IDE 320gig HD
Reply With Quote
  #3  
Old 23-02-2010
Solitario's Avatar
Member
 
Join Date: Aug 2006
Posts: 220
Re: How to use XML DOM in PHP?

For using the XML DOM you need to write an XML file, so I have given you the sample of the coding which can be useful for you :
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<note>
<to>Jack</to>
<from>Panni</from>
<heading>Reminder</heading>
<body>There is Party Tomorrow!</body>
</note>
__________________
I do to dead flowers what people at morgues do to dead people. Suck all the moisture out, dip them in plastic, paint them up pretty and put them in a nice frame.
Reply With Quote
  #4  
Old 23-02-2010
MindSpace's Avatar
Member
 
Join Date: Feb 2008
Posts: 1,832
Re: How to use XML DOM in PHP?

You can load and do the output a XML file using the following code :
Code:
<?php
$xmlDoc = new DOMDocument();
$xmlDoc->load("demo.xml");

print $xmlDoc->saveXML();
?>
The example above creates a DOMDocument-Object and loads the XML from "demo.xml" into it.
Reply With Quote
  #5  
Old 23-02-2010
Reegan's Avatar
Member
 
Join Date: Oct 2005
Posts: 2,299
Re: How to use XML DOM in PHP?

You will have to loop through an XML, for doing that you can use the following code :
PHP Code:
<?php
$xmlDoc 
= new DOMDocument();
$xmlDoc->load("demo.xml");

$x $xmlDoc->documentElement;
foreach (
$x->childNodes AS $item)
  {
  print 
$item->nodeName " = " $item->nodeValue "<br />";
  }
?>
Reply With Quote
Reply

  TechArena Community > Software > Software Development


Thread Tools Search this Thread
Search this Thread:

Advanced Search



All times are GMT +5.5. The time now is 07:36 AM.