Hi Vieira and welcome to our board!
When you say "write in an XML file through a textbox" do you mean:
a) save the InfoPath form as an XML file?
b) save the value in the textbox to a separate XML file?
c) save an XML value in the textbox to a separate XML file?
d) other?
For a) that is default behavior of InfoPath.
For b) you'll need to write some logic and make the form full trust
For c) you can write logic to start another InfoPath form and save from that...
I guess I need more description of your scenario...
Patrick Halstead [InfoPath MVP]
InfoPathDev
Patrick Halstead
Project Manager at Qdabra