BizTalk Utilities CV ,   Jobs ,   Code library  
 
Home Page
PHP XML
PHP DOMElement Function removeAttribute
PHP DOMElement Function hasAttributeNS
PHP DOMElement Function getAttribute
PHP DOMDocument Function getElementsByTagNameNS
PHP DOMDocument Function xinclude
PHP DOMDocument Function validate
PHP DOMDocument Function setAttributeNS
PHP DOMDocument Function setAttribute
PHP DOMDocument Function schemaValidateSource (handling errors)
PHP DOMDocument Function schemaValidateSource
PHP DOMDocument Function schemaValidate
PHP DOMDocument Function saveXML
PHP DOMDocument Function saveHTMLFile
PHP DOMDocument Function saveHTML
PHP DOMDocument Function normalize
PHP DOMDocument Function loadXML
PHP DOMDocument Function loadHTMLFile
PHP DOMDocument Function loadHTML
PHP DOMDocument Function importNode
PHP DOMElement Function hasAttribute
 
 

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

 

DOMElement Function removeAttributeNode

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 removes attribute node from an element.

Usage:

boolDOMElement->removeAttributeNode ( object oldnode)

Removes attribute oldnode from the element.

Throws DOMException if node cannot be modified or attribute is not a member of the element node.

PHP Code:

<?php

$xmlstr = <<<XML

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

<employee>

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

            <employeeaddress>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 employeename

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

//remove id attribute from the employeename element.

$idattr = $employeename->getAttributeNode('id');

$success = $employeename ->removeAttributeNode($idattr);

//echo out the modified DOM Document

echo "<HTML>";

echo "<Head>";

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

echo "<Head>";

echo "<body>";

echo "<PRE>";

//echo out the XML tree using saveXML() and echo function.

if($success){

echohtmlentities($dom->saveXML());

}else{

echo "Error removing attribute";

}

echo "</PRE>";

echo "</body>";

echo "</HTML>";

?>

Output:

id attribute is not there in employee name element.


Rate this article on a scale of 1 to 10

Your vote :  


 

Recent Jobs

An immediate job opportunity as a B
Software Developers Needed in Charl
Sr. Software Engineer - Analytics
Immediate Mainframe openings for Ch
Immediate TANDEM-TAL openings for C

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



answering service
soccer drills
swimming pool builder
help desk support
water softener
Teleconference
Host Department NOLIMIT Web Hosting
MSN
sunglasses


    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