PHP Outputting XML file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • chuy08@gmail.com

    PHP Outputting XML file

    I am trying to create an XML file using a PHP script. The XML File
    looks something like this:

    <?xml version="1.0" encoding="ISO-8859-1"?>
    <ConsumerDirect XML>
    <UserParams id="1" BrokerID="1"/>
    <LoanParams>
    <FirstLeinAmt>5 00000</FirstLeinAmt>
    <ChooseProductT ypeID>1</ChooseProductTy peID>
    </LoanParams>
    </ConsumerDirectX ML>

    The part that I don't understand is the following. I have a series of
    checkboxes with each box having a different value. If a user were to
    select 3 checkboxes I need to iterate through the array and write to
    the ChooseProductTy peID field in the XML file as such,
    <ChooseProductT ypeID>1,5,7</ChooseProductTy peID>. I have been able to
    print out the array variable $num using the following foreach loop:

    foreach ($total as $num) {
    print("$num,"); }

    How would I get this string into the designated XML tag?

    Currently I am able to write to this XML file using textboxes and the
    following code for different XML tags in same file. How would I modify
    what I am currently using for textboxes to use for the checkboxes while
    utilitzing the foreach loop. Below is the method by which I am
    writting to my XML file:

    if ($node_name == "FirstLeinA mt") {
    if ($value == $firstlein) {
    // Do nothing
    } else {
    $fl_textnode = $child_obj->firstChild;
    $new_firstlein = $doc->createTextNode ($firstlein);
    $child_obj->replaceChild($ new_firstlein, $fl_textnode);
    }
    }
    foreach ($total as $num) {
    if ($node_name == "ChoosedProduct TypeID") {
    if ($value == $num) {
    // Do nothing
    } else {
    $pt_textnode = $child_obj->firstChild;
    $new_num = $doc->createTextNode ("$num,");
    $child_obj->replaceChild(" $new_num", "$pt_textnode") ;
    }}
    ....


    Any help appreciated.

Working...