XML is a markup language for encoding data in machine (and human) readable format. It is designed for simplicity and portability. XML tags are written using angle brackets <>, with the tag name and attributes inside in the format <tag attribute="value">.
Some Ideas for Challenges:
-Define your own XML format. This can be done using a number of schemas, including a Document Type Definition (DTD) or an XML Schema.
-Experiment with some XML parsing APIs including SAX, DOM, and a pull parser. Possibly work with the DIC API.
-Layout XML using CSS or XSLT
-Write a program to generate XML from existing data, perhaps including a SQL result set
Resources:
-W3Schools
-W3C XML Documentation
-KYA's Blog Entries on Parsing XML in Java and C#
-DIC API Feedback and Support forum
My Entry: My Write Columns of Table To XML snippet.
/*
@param $result: the result set from the SQL query
@param $cols: the array of column names
@param $filename: the name of the File to create
@param $tagName: The name of the container tag for each row
<pre>The File is assumed to not exist</pre>
*/
public function queryToXML($result, array $cols, $filename, $tagName){
$file = fopen($filename, "w"); //open up file stream
//write initial XML heading
fwrite($file, "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n");
//foreach row
while($row = mysql_fetch_array($result)){
fwrite($file, "<".$tagName.">\n");
//write data using col name as tag
foreach($cols as $tag){
fwrite($file,"\t<".$tag.">".$row[$tag]."</".$tag.">\n");
}//end foreach
//close row tag
fwrite($file,"</".$tagName.">\n");
}//end while
fclose($file);
}//end queryToXML()

New Topic/Question
Reply





MultiQuote







|