Changeset 82
- Timestamp:
- 01/17/07 15:10:13 (2 years ago)
- Files:
-
- trunk/src/main/php/xml/stubXMLDomStreamWriter.php (modified) (1 diff)
- trunk/src/main/php/xml/stubXMLStreamWriter.php (modified) (1 diff)
- trunk/src/test/php/xml/stubXMLDomStreamWriterTestCase.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main/php/xml/stubXMLDomStreamWriter.php
r65 r82 130 130 131 131 /** 132 * Write a full element 133 * 134 * @param string $elementName 135 * @param array $attributes 136 * @param string $cdata 137 */ 138 public function writeElement($elementName, array $attributes = array(), $cdata = null) { 139 $element = $this->doc->createElement($elementName); 140 foreach ($attributes as $attName => $attValue) { 141 $element->setAttribute($attName, $attValue); 142 } 143 if (null !== $cdata) { 144 $element->appendChild($this->doc->createTextNode($cdata)); 145 } 146 if (count($this->elementStack) == 0) { 147 $this->doc->appendChild($element); 148 } else { 149 $parent = end($this->elementStack); 150 $parent->appendChild($element); 151 } 152 153 } 154 155 /** 132 156 * Import another stream 133 157 * trunk/src/main/php/xml/stubXMLStreamWriter.php
r31 r82 81 81 82 82 /** 83 * Write a full element 84 * 85 * @param string $elementName 86 * @param array $attributes 87 * @param string $cdata 88 */ 89 public function writeElement($elementName, array $attributes = array(), $cdata = null); 90 91 /** 83 92 * Import another stream 84 93 * trunk/src/test/php/xml/stubXMLDomStreamWriterTestCase.php
r31 r82 41 41 } 42 42 43 /** 44 * Test creating a document with several tags 45 */ 46 public function testFullElement() { 47 $writer = new stubXMLDomStreamWriter(); 48 $writer->writeElement('foo', array('att' => 'value'), 'content'); 49 50 $this->assertEqual('<?xml version="1.0" encoding="ISO-8859-1"?>' . "\n" . '<foo att="value">content</foo>' . "\n" , $writer->asXML()); 51 } 52 43 53 /** 44 54 * Test creating a document with attributes
