This site has been taken over by the staff of www.ASPDeveloper.Net

Please report errors to suggest@aspdeveloper.net

BizTalk Utilities CV ,   Jobs ,   Code library  
 
Home Page
PHP XML
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
How to install PHP in different environment
Simple XSLT transformation with PHP 4.1.0 and Sablotron
 
 

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 :975

 

DOMDocument Function getAttributeNodeNS

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 retrieves the attribute node with a specified name space.

The functionality is same as getAttributeNode() function.

Usage:

objectDOMElement->getAttributeNodeNS ( string namespaceURI, string localName)

Returns the attribute node in namespace namespaceURI with local name localName for the current node.

PHP Code:

<?php

$xmlstr = <<<XML

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

<employee>

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

            <employeeaddressxmlns:prefix="myNS" prefix:street="times square">test123</employeeaddress>

            <SSN>12343456</SSN>

            <company>XYZ Corporation</company>

</employee>

XML;

$dom = new domDocument;

//load the XML string into the DOM

$dom->loadXML($xmlstr);

//retrieve the first element with name employeeaddress

$employeeaddr = $dom->getElementsByTagName('employeeaddress')->item(0);

//retrive the street attribute Node.

$attrNode = $employeeaddr ->getAttributeNodeNS('myNS','street');

//echo out the content

echo "<HTML>";

echo "<Head>";

echo "<title>Example of getAttributeNS </title>";

echo "<Head>";

echo "<body>";

echo "<B>";

echo "Name of the attribute node is :".$attrNode->name;

echo "<BR>Name of the attribute node is :".$attrNode->value;

echo "</B>";

echo "<body>";

echo "<HTML>";

?>

Output:


Rate this article on a scale of 1 to 10

Your vote :  


 

Recent Jobs

Software Specialist, Linux - Finlan
Linux Core Technical Project Manage
Graphics designer at Tanzania. Expe
Integration Specialist Needed - Wor
Virtualization Server Infrastructur

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






    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