J
Joel Witherspoon
I'm generating an xml file using PHP DOMXML . I'm able to create and
edit the file fine, however the formatting of my file is off. Instead
of being the standard xml:
<?xml version="1.0">
<root>
<element>
</element>
</root>
I am getting:
<?xml version="1.0">
<root>
<element></element></root>
Here is the code:
PHP:
$tdindex = time(); //creates unix time var for indexing
$doc = domxml_new_doc('1.0');
$root = $doc->add_root('categories');
$category = $doc->create_element('category');
$category = $root->append_child($category);
$category->set_attribute('index',$tdindex);
$cattext = $doc->create_text_node($cat);
$cattext = $category->append_child($cattext);
$description =
$doc->create_element('description');
$description =
$category->append_child($description);
$desctext = $doc->create_text_node($desc);
$desctext =
$description->append_child($desctext);
//create file if it doesn't exist and dump memory into it
$filename = realpath('categories.xml');
$doc->dump_file($filename, false, true);
Is there an method in DOMXML that formats the file? I thought
dump_file or dump_mem handled it.
Any help is appreciated.
__________________Joel
<<<<<<<<<<<<<<<<<<<<<<<
edit the file fine, however the formatting of my file is off. Instead
of being the standard xml:
<?xml version="1.0">
<root>
<element>
</element>
</root>
I am getting:
<?xml version="1.0">
<root>
<element></element></root>
Here is the code:
PHP:
$tdindex = time(); //creates unix time var for indexing
$doc = domxml_new_doc('1.0');
$root = $doc->add_root('categories');
$category = $doc->create_element('category');
$category = $root->append_child($category);
$category->set_attribute('index',$tdindex);
$cattext = $doc->create_text_node($cat);
$cattext = $category->append_child($cattext);
$description =
$doc->create_element('description');
$description =
$category->append_child($description);
$desctext = $doc->create_text_node($desc);
$desctext =
$description->append_child($desctext);
//create file if it doesn't exist and dump memory into it
$filename = realpath('categories.xml');
$doc->dump_file($filename, false, true);
Is there an method in DOMXML that formats the file? I thought
dump_file or dump_mem handled it.
Any help is appreciated.
__________________Joel
<<<<<<<<<<<<<<<<<<<<<<<