Unix and Linux Discussions Tagged with unix scripting basics |
|
Thread / Thread Starter |
Last Post |
Replies |
Views |
Forum |
|
|
|
409 |
426,768 |
Open Source |
|
|
|
192 |
262,414 |
Open Source |
|
|
|
249 |
284,315 |
UNIX for Advanced & Expert Users |
|
|
|
182 |
210,976 |
SuSE |
|
|
|
1 |
5,003 |
Shell Programming and Scripting |
|
|
|
61 |
49,375 |
Web Development |
|
|
|
1 |
5,344 |
Shell Programming and Scripting |
|
|
|
54 |
43,217 |
What is on Your Mind? |
|
|
|
29 |
20,961 |
What is on Your Mind? |
|
|
|
11 |
32,694 |
Shell Programming and Scripting |
|
|
|
11 |
29,033 |
Shell Programming and Scripting |
|
|
|
13 |
141,989 |
Shell Programming and Scripting |
|
|
|
6 |
12,843 |
UNIX for Dummies Questions & Answers |
|
|
|
4 |
11,381 |
Shell Programming and Scripting |
|
|
|
15 |
54,733 |
Gentoo |
|
|
|
7 |
30,016 |
Shell Programming and Scripting |
|
|
|
3 |
55,063 |
Shell Programming and Scripting |
|
|
|
52 |
375,074 |
Shell Programming and Scripting |
|
|
|
11 |
14,605 |
UNIX for Dummies Questions & Answers |
|
|
|
8 |
8,988 |
Shell Programming and Scripting |
|
|
|
10 |
28,530 |
OS X (Apple) |
|
|
|
6 |
5,880 |
UNIX for Dummies Questions & Answers |
|
|
|
5 |
14,745 |
Windows & DOS: Issues & Discussions |
|
|
|
12 |
10,134 |
UNIX for Dummies Questions & Answers |
|
|
|
10 |
9,859 |
Shell Programming and Scripting |
|
|
|
4 |
32,677 |
UNIX Desktop Questions & Answers |
|
|
|
3 |
7,325 |
Programming |
|
|
|
4 |
33,591 |
Linux |
|
|
|
7 |
23,556 |
Shell Programming and Scripting |
|
|
|
4 |
15,487 |
Programming |
|
|
|
2 |
5,147 |
Shell Programming and Scripting |
|
|
|
3 |
13,408 |
Shell Programming and Scripting |
|
|
|
4 |
28,071 |
Shell Programming and Scripting |
|
|
|
3 |
9,418 |
Shell Programming and Scripting |
|
|
|
5 |
6,167 |
Shell Programming and Scripting |
|
|
|
2 |
2,995 |
Shell Programming and Scripting |
|
|
|
6 |
58,495 |
UNIX for Dummies Questions & Answers |
|
|
|
7 |
30,229 |
Solaris |
|
|
|
11 |
8,081 |
Shell Programming and Scripting |
|
|
|
1 |
23,884 |
Shell Programming and Scripting |
DOMDOCUMENT.GETELEMENTBYID(3) 1 DOMDOCUMENT.GETELEMENTBYID(3)
DOMDocument::getElementById - Searches for an element with a certain id
SYNOPSIS
public DOMElement DOMDocument::getElementById (string $elementId)
DESCRIPTION
This function is similar to "DOMDocument::getElementsByTagName" but searches for an element with a given id.
For this function to work, you will need either to set some ID attributes with "DOMElement::setIdAttribute" or a DTD which defines an
attribute to be of type ID. In the later case, you will need to validate your document with "DOMDocument::validate" or DOMDocument::$vali-
dateOnParse before using this function.
PARAMETERS
o $elementId
- The unique id value for an element.
RETURN VALUES
Returns the DOMElement or NULL if the element is not found.
EXAMPLES
Example #1
DOMDocument::getElementById() Example
The following examples use book.xml which contains the following:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE books [
<!ELEMENT books (book+)>
<!ELEMENT book (title, author+, xhtml:blurb?)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT blurb (#PCDATA)>
<!ELEMENT author (#PCDATA)>
<!ATTLIST books xmlns CDATA #IMPLIED>
<!ATTLIST books xmlns:xhtml CDATA #IMPLIED>
<!ATTLIST book id ID #IMPLIED>
<!ATTLIST author email CDATA #IMPLIED>
]>
<?xml-stylesheet type="text/xsl" href="style.xsl"?>
<books xmlns="http://books.php/" xmlns:xhtml="http://www.w3.org/1999/xhtml">
<book id="php-basics">
<title>PHP Basics</title>
<author email="jim.smith@basics.php">Jim Smith</author>
<author email="jane.smith@basics.php">Jane Smith</author>
<xhtml:blurb><![CDATA[
<p><em>PHP Basics</em> provides an introduction to PHP.</p>
]]></xhtml:blurb>
</book>
<book id="php-advanced">
<title>PHP Advanced Programming</title>
<author email="jon.doe@advanced.php">Jon Doe</author>
</book>
</books>
<?php
$doc = new DomDocument;
// We need to validate our document before refering to the id
$doc->validateOnParse = true;
$doc->Load('book.xml');
echo "The element whose id is 'php-basics' is: " . $doc->getElementById('php-basics')->tagName . "
";
?>
The above example will output:
The element whose id is 'php-basics' is: book
SEE ALSO
DOMDocument::getElementsByTagName.
PHP Documentation Group DOMDOCUMENT.GETELEMENTBYID(3)