BizTalk Utilities CV ,   Jobs ,   Code library  
 
Home Page
PHP XML
PHP DOMDocument Function getAttributeNS
PHP DOMDocument Function getAttributeNodeNS
PHP DOMDocument Function getAttribute
PHP DOMDocument Function createTextNode
PHP DOMDocument Function createProcessingInstruction
PHP DOMDocument Function createEntityReference
PHP DOMDocument Function createElementNS
PHP DOMDocument Function createElement
PHP DOMDocument Function createDocumentFragment
PHP DOMDocument Function createComment
PHP DOMDocument Function createCDATASection
PHP DOMDocument Function createAttributeNS
PHP DOMDocument Function createAttribute
PHP DOMCharacterData Function substringData
PHP DOMCharacterData Function replaceData
PHP DOMCharacterData Function insertData
PHP DOMCharacterData Function deleteData
PHP DOMCharacterData Function appendData
PHP DOMAttr Function isId
DOM Functions
 
 

By :Mark Wilson
I am the creator of TopXML. I am available for international and local (Australia) contracts. I am a Solution Architect/Business Analyst. I have worked in IT in several countries (NZ, Australia, South Africa, UK) building and training teams for government and very large non-governmental organizations. I am ex-Microsoft Consulting Services. I wrote the first book on Microsoft XML published in 2000 called XML Programming with VB and ASP. Most recently I have been building tools for the SEO industry. Ask me for a 37 point SEO health-checkup for your website.
First posted :03/24/2008
Times viewed :4139

 

DOMDocument Function getElementsByTagName

PHP Version: (No version information might be only in CVS. I have used this function in PHP5)

DOM: W3C DOM Level 1

Description

This function searches XML document for a given element name and returns all elements as a DOMNodeList object.

Usage:

object DOMDocument->getElementsByTagName ( string name)

This function returns a new instance of class DOMNodeList containing the elements with tagnames matching the name parameter.

Use "*" for the name to return all elements within the document.

Example:

The XML file, which I have used contains following data. I have stored this file in “c:/topxml_demo/php/xml_files/employee.xml” directory.

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

<employee>

     <employeename id="123456">test</employeename>

     <employeeaddress>test123</employeeaddress>

     <SSN>12343456</SSN>

     <company>TOPXML</company>

     </employee>

PHP Code:

<?php

    $doc = new DomDocument;

// Load the xml file into DOMDocument

$doc->Load('C:/topxml_demo/php/xml_files/employee.xml');

// We retrieve the employeename elements and return the first element.

$employee = $doc->getElementsByTagName('employeename')->item(0);

//Echo out Id attribute of the employee element

echo  "<B> id of employee is</B> :".$employee->getAttribute('id');

 echo "<BR><B>DOMDocument->getElementsByTagName example<B>"

 ?>

Output:


Rate this article on a scale of 1 to 10

Your vote :  


 

Recent Jobs

Integration Specialist Needed - Wor
Virtualization Server Infrastructur
A great opportunity to Digital Vide
here is a greate opportunity as a S
A great opportunity as a Network En

View all Jobs (Add yours)
View all CV (Add yours)




Web Hosting
TMobile G1 Accessories
help desk support


    Email TopXML  

Front Page Daily Stuff TopXML Forum XML blogs XML Newsgroups BizTalk Biztalk Utilities Biztalk Utilities Tutorial B2B SAP XML Microsoft .NET Dotnet System XML Soapformatter SQLXML XMLserializer XQuery PHP PHP SimpleXML PHP XML Dom PHP XML RPC PHP XSLT Java Java Java XML Xalan Microsoft ASP ASP Schemas XML SQL Server XML XMLDom XSL XSL Tutorial XSLT Stylesheets General Javascript CSS XHTML WAP