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

 

DOMAttr Function isId

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

Description

This function checks if the attribute is a defined ID and returns success if it is ID. According to the DOM standard this requires a DTD which defines the attribute ID to be of type ID. You need to validate your document with

Using DOMDocument->validate() function or DOMDocument::validateOnParse before using this function.

Usage:

bool DOMAttr->isId ( void )

This function will check whether the attribute is ID. If attribute of type ID then it returns TRUE otherwise returns FALSE.

Example:

The DTD which I have written with ID as attribute is:

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

<!ELEMENT SSN (#PCDATA)>

<!ELEMENT company (#PCDATA)>

<!ELEMENT employee (employeename, employeeaddress, SSN, company)>

<!ATTLIST employee

     id ID #REQUIRED <!--the id attribute is of type ID-->

>

<!ELEMENT employeeaddress (#PCDATA)>

<!ELEMENT employeename (#PCDATA)>

The XML file is:

     <?xml version="1.0"?>

<!DOCTYPE employee SYSTEM "C:/topxml_demo/php/xml_files/employee.dtd">

<employee id="Id111">

     <employeename>test</employeename>

     <employeeaddress>test123</employeeaddress>

     <SSN>12343456</SSN>

     <company>TOPXML</company>

</employee>

PHP code file content:

     <html>

          <head>

               <title>Usage of DOMAttr->isId</title>

 </head>

          <body>

          <?php

               //I created a new DOMDocument

               $doc = new DomDocument;

               // We need to validate our document before refering to the id

               $doc->validateOnParse = true;

               //Load the save.xml file into DOMDocument

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

               // We retrieve the attribute named id of the employee element

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

               //printed by using isId() function to check whether “id” is of type ID or not

              

               var_dump($attr->isId()); // bool(true)

          ?>

          </body>

</html>

Output:

bool(true)

It returned true because the id attribute is of type ID.


Rate this article on a scale of 1 to 10

Your vote :  


 

Recent Jobs

A great opportunity to Digital Vide
here is a greate opportunity as a S
A great opportunity as a Network En
A Greate Opportunituy as a SQL Deve
An immediate job opportunity as a B

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



Information Online

swimming pool contractor
chicago web site design
desktop fax online
Domain Names
unlimited conferencing
Dolce&gabbana sunglasses
answering service


    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