from a text file */ function doc1fromText($fileName){ $doc = new DOMDocument(); $root = $doc->createElement("list"); $doc->appendChild($root); $lines = file($fileName); foreach( $lines as $line ){ $name_mark = split("[ \t]+", $line); $the_name = $name_mark[0]; $the_mark = rtrim($name_mark[1]); $stud = $doc->createElement("student"); $root->appendChild($stud); $stud->setAttribute("name", $the_name); $stud->setAttribute("mark", $the_mark); } return $doc; }// doc1fromText function build1fromText($fileIn, $fileOut){ $doc = doc1fromText($fileIn); $doc->save($fileOut); } build1fromText($argv[1], $argv[2]); ?>