Souza
Souza

Reputation: 1143

PHP to XML after submiting form from html

Well, i have this thing, i need to edit a XML file that is pre-formated, only need to change some variables:

This is the XML i have by defauld and i need to edit some "fields":

        <clstamp>TS11030954594,1410000-1</clstamp>
    <nome>**Carlos Raul**</nome>
    <no>764</no>
    <estab>0</estab>
    <vendnm/>
    <ncont>**236730339**</ncont>
    <nome2/>
    <saldo>.00000</saldo>
    <esaldo>.000000</esaldo>
    <moeda>EURO</moeda>
    <fax/>
    <telefone>**969273816**</telefone>
    <contacto/>
    <acmfact>14041.75928</acmfact>
    <eacmfact>70.040000</eacmfact>
    <rentval>.00000</rentval>
    <erentval>.000000</erentval>
    <eem>false</eem>
    <emno>0</emno>
    <eag>false</eag>
    <agno>0</agno>
    <eid>false</eid>
    <idno>0</idno>
    <efl>false</efl>
    <flno>0</flno>
    <flestab>0</flestab>
    <morada>**Rua Cidade Rio Maior Lote 244**</morada>
    <local>**Odivelas**</local>
    <codpost>**1675-674 Famões**</codpost>

The data in bold would be introduced using a form, i thought of doing something like this:

    <clstamp>TS11030954594,1410000-1</clstamp>
    <nome>**.$name**</nome>
    <no>764</no>
    <estab>0</estab>
    <vendnm/>
    <ncont>**.$Telefone**</ncont>
    <nome2/>
    <saldo>.00000</saldo>
    <esaldo>.000000</esaldo>
    <moeda>EURO</moeda>
    <fax/>
    <telefone>.$Cellphone</telefone>
    <contacto/>
    <acmfact>14041.75928</acmfact>
    <eacmfact>70.040000</eacmfact>
    <rentval>.00000</rentval>
    <erentval>.000000</erentval>
    <eem>false</eem>
    <emno>0</emno>
    <eag>false</eag>
    <agno>0</agno>
    <eid>false</eid>
    <idno>0</idno>
    <efl>false</efl>
    <flno>0</flno>
    <flestab>0</flestab>
    <morada>**.$Adress**</morada>
    <local>**.$City**</local>
    <codpost>**.$Postcode**</codpost>

I could make the output a simple plain html and than export the file changing manualy the mime-type to *.XML

I've heard about xwdt or something, but haven't investigated this. Do you people have some sugestions to give me?

Thanks very much guys!

Upvotes: 0

Views: 313

Answers (1)

Gavin Coates
Gavin Coates

Reputation: 1425

Do you need to write the XML out to a file on the web server? If so, you dont need to worry about mime types, just output the XML direct to a file as a text string.

here is a good tutorial on how to write to a file: http://www.tizag.com/phpT/filewrite.php

The code you listed in the second example will be fine, just save it into a variable then write it out using fwrite.

Upvotes: 1

Related Questions