BizTalk Utilities CV ,   Jobs ,   Code library  
 
Home Page
PHP XML
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 :488

 

DOMCharacterData Function appendData

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

DOM: W3C DOM Level 1

Description

Append the string to the end of the character data of the node. The node is a DOM node.

Usage:

void DOMCharacterData->appendData ( string data)

Append the string data to the end of the character data of the node.

Example:

The XML file, which I have used contains

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

<employee>

            <employeename>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 attribute named id of the employee element

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

//Create a new Element

$newElement = $doc ->createElement('surname');

//create a Text Node

$textNode = $doc ->createTextNode ("Text Node Created");

//append the Text Node into the newly created node

$newElement -> appendChild($textNode);

//append the new element to the employee element

$employee  -> appendChild($newElement);

//save the DOMDocument into a file

$test = $doc->save("C:/topxml_demo/php/xml_files/save1.xml");

 echo "<B>DOMCharacterData->appendData example<B>"

 ?>

Output:

The Content of save1.xml is

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

<employee>

               <employeename>test</employeename>

               <employeeaddress>test123</employeeaddress>

               <SSN>12343456</SSN>

               <company>TOPXML</company>

               <!-- I created a element and added text node into the new element -->

               <surname>Text Node Created</surname>

</employee>


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)




Chicago Web Site Design
help desk support
conference call review
Fendi sunglasses
air freshener
odor remover


    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