Ok, I have XML like this (XML Exhibit A) that I read in from a file
ala .. $doc->load("./Template.xml"); because I could not figure out
how to set the !DOCTYPE element.
------ XML Exhibit A-----
<?xml version="1.0" standalone="no" ?>
<!DOCTYPE graph SYSTEM "graph.dtd" >
<graph/>
--------------
I would like to change <graph/> to be like <graph start="e-2h" end="N"
width="600" height="300"/> But when I try it (using Code Exhibit A) I
get "<graph/><graph start="e-2h" end="N" wi...."
------ Code Exhibit A ------
$doc = new DomDocument('1. 0','UTF-8');
$doc->load("./Template.xml");
// create root node
$graph = $doc->documentElemen t;
$graph->setAttribute(' start', 'e-2h');
$graph->setAttribute(' end', 'N');
$graph->setAttribute(' width', '600');
$graph->setAttribute(' height', '300');
$newNode = $doc->appendChild($g raph);
---------------------
So I guess in the end I have two questions.
#1 How do you set "<!DOCTYPE graph SYSTEM "graph.dtd" >"?
#2 How to you modify an existing node?
ala .. $doc->load("./Template.xml"); because I could not figure out
how to set the !DOCTYPE element.
------ XML Exhibit A-----
<?xml version="1.0" standalone="no" ?>
<!DOCTYPE graph SYSTEM "graph.dtd" >
<graph/>
--------------
I would like to change <graph/> to be like <graph start="e-2h" end="N"
width="600" height="300"/> But when I try it (using Code Exhibit A) I
get "<graph/><graph start="e-2h" end="N" wi...."
------ Code Exhibit A ------
$doc = new DomDocument('1. 0','UTF-8');
$doc->load("./Template.xml");
// create root node
$graph = $doc->documentElemen t;
$graph->setAttribute(' start', 'e-2h');
$graph->setAttribute(' end', 'N');
$graph->setAttribute(' width', '600');
$graph->setAttribute(' height', '300');
$newNode = $doc->appendChild($g raph);
---------------------
So I guess in the end I have two questions.
#1 How do you set "<!DOCTYPE graph SYSTEM "graph.dtd" >"?
#2 How to you modify an existing node?
Comment