Example #1
0
    public function testNonAssocArrayConfigured()
    {
        $actual = array(1, 5, 2, 'some', null);
        $expected_xml = '<root>
<key0>1</key0>
<key1>5</key1>
<key2>2</key2>
<key3>some</key3>
<key4></key4>
</root>';
        $this->array2xml->setEmptyElementSyntax(Array2xml::EMPTY_FULL);
        $this->array2xml->setSkipNumeric(FALSE);
        $this->execute($expected_xml, $actual);
    }
Example #2
0
	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);
	}