Novex
May 17th, 2002, 06:07
some help could be....helpful ;)
Im halfway through learning xml (with flash but Ive got that underway) and comes the time to write variables to the xml file I figured the best way to do this would probably be using PHP (cause flash doent have inbuilt support)
so far using my basic knowledge (and some things Ive assumed from some code samples) Ive come up with something like this
// Assign the XML data to a variable
//im assuming the .= means add the string to the variable, please correct me if im wrong
$xml = "<article>\r\n";
$xml .= " <url>$url</url>\r\n";
$xml .= " <headline_text>$headline_text</headline_text>\r\n";
$xml .= " <source>18</source>\r\n";
$xml .= " <category>$myvar</category>\r\n";
$xml .= "</article>";
$fp = fopen("data.xml", "a"); //a is write only
fwrite($fp, $xml); // Write the XML data to the file with the point $fp
fclose($fp); // Close the file
for anyone who doesnt know about XML, my code looks something like this
<?xml version="1.0" encoding="iso-8859-1" ?>
<data>
<article>
<url>http://www.txdc.tk</url>
<headline_text>TXDC</headline_text>
<source>Hezza</source>
<category>Shameless Plug</category>
</article>
<article>
<url>http://www.flashkit.com</url>
<headline_text>Flashkit</headline_text>
<source>Actionscripter</source>
<category>Flashness</category>
</article>
</data>
thats all Ive gotten so far, it should write the variables and everything in the tags, but now all my problem is to get it to write the <article> tag (and all the ones contained in it) in between the <data></data> tag, requiring that the php finds the tag and writes the <article> tag inside it...
any ideas would help:classic2: :chinese2: :)
thanks
Im halfway through learning xml (with flash but Ive got that underway) and comes the time to write variables to the xml file I figured the best way to do this would probably be using PHP (cause flash doent have inbuilt support)
so far using my basic knowledge (and some things Ive assumed from some code samples) Ive come up with something like this
// Assign the XML data to a variable
//im assuming the .= means add the string to the variable, please correct me if im wrong
$xml = "<article>\r\n";
$xml .= " <url>$url</url>\r\n";
$xml .= " <headline_text>$headline_text</headline_text>\r\n";
$xml .= " <source>18</source>\r\n";
$xml .= " <category>$myvar</category>\r\n";
$xml .= "</article>";
$fp = fopen("data.xml", "a"); //a is write only
fwrite($fp, $xml); // Write the XML data to the file with the point $fp
fclose($fp); // Close the file
for anyone who doesnt know about XML, my code looks something like this
<?xml version="1.0" encoding="iso-8859-1" ?>
<data>
<article>
<url>http://www.txdc.tk</url>
<headline_text>TXDC</headline_text>
<source>Hezza</source>
<category>Shameless Plug</category>
</article>
<article>
<url>http://www.flashkit.com</url>
<headline_text>Flashkit</headline_text>
<source>Actionscripter</source>
<category>Flashness</category>
</article>
</data>
thats all Ive gotten so far, it should write the variables and everything in the tags, but now all my problem is to get it to write the <article> tag (and all the ones contained in it) in between the <data></data> tag, requiring that the php finds the tag and writes the <article> tag inside it...
any ideas would help:classic2: :chinese2: :)
thanks