Beispiel #1
0
 public function testRootAttrs()
 {
     $actual = array('foo' => 'text');
     $expected = '<root someAttr="value" someOtherAttr="some value"><foo>text</foo></root>';
     $this->array2xml->setRootAttrs(array('someAttr' => 'value', 'someOtherAttr' => 'some value'));
     $this->execute($expected, $actual);
 }
	public function getXML() {
		$array2xml = new Array2xml();
		$array2xml->setRootName('items');
		$array2xml->setNumericElement('item');
		$array2xml->setSkipNumeric(false);
		$namespaces = array(
			'xmlns' => "http://example.com/ns/#",
			'xmlns:ic' => "http://imi.ipa.go.jp/ns/core/2",
			'xmlns:dct' => "http://purl.org/dc/terms/",
			'xmlns:xsi' => "http://www.w3.org/2001/XMLSchema-instance",
			'xsi:noNamespaceSchemaLocation' => "./schema.xsd",
		);
		$id = array();
		$output = array();
		foreach ( $this->items as $item ) {
			if ( $this->checkHeaderSkip() ) {
				continue;
			}
			$not_empty = false;
			foreach($item as $cell){
				if(!empty($cell)){
					$not_empty = true;
					break;
				}
			}
			if(!$not_empty){
				continue;
			}
			$id[] = array('id' => $this->project['eg:vocabulary']['eg:uri'] . $this->getSubject($item));
			$output[] = $this->setPropertyRecursive( $item, $this->property );
		}
		$array2xml->setElementsAttrs($id);
		$array2xml->setRootAttrs($namespaces);
		return $array2xml->convert($output);
	}