Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > create (and write into) an xml file from data given in a form

Reply
Thread Tools

create (and write into) an xml file from data given in a form

 
 
despo
Guest
Posts: n/a
 
      12-18-2009
Hi
I am sorry if this is discussed elsewhere, but I have searched a lot
and could not find anything concrete (for my standards of course). I
have found a lot of examples of how to write in xml tagged format, but
all of them seem to print in alert boxes or similar, so I cannot see
how I can CREATE a new xml file. Also I have found a lot about
creating ActiveXObjects (IE targets), but this is not what i want.

I would be grateful if somebody could help me on this. To be more
exact, i would like something of the form
- create new file of name "newfile.xml"
- write "anything" in "newfile.xml"

thanks a lot in advance
 
Reply With Quote
 
 
 
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      12-18-2009
despo wrote:

> I am sorry if this is discussed elsewhere, but I have searched a lot
> and could not find anything concrete (for my standards of course).


Naming the parameters of your search would have helped us to suggest better
ones.

> I have found a lot of examples of how to write in xml tagged format, but
> all of them seem to print in alert boxes or similar, so I cannot see
> how I can CREATE a new xml file. Also I have found a lot about
> creating ActiveXObjects (IE targets), but this is not what i want.


ActiveX/COM objects are certainly one way to go (not only for Internet
Explorer). What else do you want, then?

> I would be grateful if somebody could help me on this. To be more
> exact, i would like something of the form
> - create new file of name "newfile.xml"
> - write "anything" in "newfile.xml"


As this requires the use of host objects, it is nearly impossible to say
without you stating your requirements, especially the target runtime
environments.

<http://jibbering.com/faq/#posting>


PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee
 
Reply With Quote
 
 
 
 
Matěj Cepl
Guest
Posts: n/a
 
      12-18-2009
Dne 18.12.2009 18:01, despo napsal(a):
> I am sorry if this is discussed elsewhere, but I have searched a lot
> and could not find anything concrete (for my standards of course). I
> have found a lot of examples of how to write in xml tagged format, but
> all of them seem to print in alert boxes or similar, so I cannot see
> how I can CREATE a new xml file. Also I have found a lot about
> creating ActiveXObjects (IE targets), but this is not what i want.


Depends on what you browsers you need to support. If not archeological
excavations (i.e., IEs ), then maybe http://en.wikipedia.org/wiki/E4X
might be helpful. See for example https://developer.mozilla.org/en/E4X.
Otherwise, in the old bad days, I am afraid, you just used
document.write a lot and wrote all your tags one by one.

> I would be grateful if somebody could help me on this. To be more
> exact, i would like something of the form
> - create new file of name "newfile.xml"
> - write "anything" in "newfile.xml"


well, concerning creating the file, you have a problem with creating any
new file from scratch. First decide what file you want ... if you mean
like real file on the local harddrive, then it is kind of complicated,
otherwise if you want a chunk of data formatted as XML send over the
wire somewhere, it is easy.

Concerning searializing forms, join the party on the current thread
"caching submitted form while we are offline?"

Matěj

--
http://www.ceplovi.cz/matej/, Jabber: mcepl<at>ceplovi.cz
GPG Finger: 89EF 4BC6 288A BF43 1BAB 25C3 E09F EF25 D964 84AC

I didn't attend the funeral, but I sent a nice letter saying
I approved of it.
-- Mark Twain
 
Reply With Quote
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      12-18-2009
Matěj Cepl wrote:

> Dne 18.12.2009 18:01, despo napsal(a):
>> I am sorry if this is discussed elsewhere, but I have searched a lot
>> and could not find anything concrete (for my standards of course). I
>> have found a lot of examples of how to write in xml tagged format, but
>> all of them seem to print in alert boxes or similar, so I cannot see
>> how I can CREATE a new xml file. Also I have found a lot about
>> creating ActiveXObjects (IE targets), but this is not what i want.

>
> Depends on what you browsers you need to support. If not archeological
> excavations (i.e., IEs ), then maybe http://en.wikipedia.org/wiki/E4X
> might be helpful. See for example https://developer.mozilla.org/en/E4X.
> Otherwise, in the old bad days, I am afraid, you just used
> document.write a lot and wrote all your tags one by one.


E4X is merely a syntax extension. It does _not_ *create files*, neither
does document.write(). If you were talking about server-side scripting,
then E4X might be an option for efficiently writing the data with e.g.
write(). But you would still need a host object (e.g. File) to do it.


PointedEars
--
Danny Goodman's books are out of date and teach practices that are
positively harmful for cross-browser scripting.
-- Richard Cornford, cljs, <cife6q$253$1$(E-Mail Removed)> (2004)
 
Reply With Quote
 
despo
Guest
Posts: n/a
 
      12-21-2009
Thank you all so much

> > I cannot see
> > how I can CREATE a new xml file. Also I have found a lot about
> > creating ActiveXObjects (IE targets), but this is not what i want.

>
> ActiveX/COM objects are certainly one way to go (not only for Internet
> Explorer). What else do you want, then?


OK, I got the impression that ActiveXObjects worked only for IE. I am
interested mainly for firefox (meaning i want what this web page to
work in any environment, but if it cannot, i would prefer it to be
functional in firefox).

> maybe http://en.wikipedia.org/wiki/E4X
> might be helpful. See for example https://developer.mozilla.org/en/E4X.


i tried to set e4x in the script declaration, but it does not seem to
change anything. And somewhere i read that it is not needed.

> E4X is merely a syntax extension. It does _not_ *createfiles*, neither
> does document.write(). If you were talking about server-side scripting,
> then E4X might be an option for efficiently writing the data with e.g.
> write(). But you would still need a host object (e.g.File) to do it.


So you mean, I should create a file, which will be used to write on
data temporarily. Then if I guess I have to allocate some space for
its potential size, right? How can i do that?

> > i would like something of theform
> > - create new file of name "newfile.xml"
> > - write "anything" in "newfile.xml"

>
> As this requires the use of host objects, it is nearly impossible to say
> without you stating your requirements, especially the target runtime
> environments.


Well, I understand that an user that uses a web site for some
calculations cannot have the permission to write in the server that
hosts the web site. But what if the user had the permission to create
a temporary file; then if he wants to save it in his hard disk, then
he has the possibility to do it, otherwise the file would be deleted
permanently. I believe there must be such a possibility, it's only i
don't know how to explain it better. Imagine some form you submit with
your personal data. On submission, the data are processed somehow, but
also the user has thew right to see what he filled in in this form.

> well, concerning creating the file, you have a problem with creating any
> new file from scratch. First decide what file you want ... if you mean
> like real file on the local hard drive, then it is kind of complicated,
> otherwise if you want a chunk of data formatted as XML send over the
> wire somewhere, it is easy.


I think that this is what i describe above, isn't it? Data formatted
as xml sent saved in the user's hard disk, or sent to an email
address. I am sorry, but i guess my vocabulary in this field a bit
limited.

> Concerning searializing forms, join the party on the current thread
> "caching submittedformwhile we are offline?"


thanks, but i checked it out, it is a bit too much for me..

Well, I think that I can prepare a very simple sample file of what i
want to do. Thank you a lot!

d
 
Reply With Quote
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      12-22-2009
despo wrote:

> Thank you all so much


Thank you for not deleting the attribution lines next time, and for posting
the followup exactly to what you are referring to, not just somewhere in the
thread as you did here.

>> > I cannot see
>> > how I can CREATE a new xml file. Also I have found a lot about
>> > creating ActiveXObjects (IE targets), but this is not what i want.

>>
>> ActiveX/COM objects are certainly one way to go (not only for Internet
>> Explorer). What else do you want, then?

>
> OK, I got the impression that ActiveXObjects worked only for IE.


They do not. What matters are the capabilities of the runtime environment,
not the name of the browser.

> I am interested mainly for firefox (meaning i want what this web page to
> work in any environment, but if it cannot, i would prefer it to be
> functional in firefox).


In that case you might want to look into XPCOM, the Cross-Platform Component
Object Model provided by Mozilla. It can be used in a privileged
environment, like a Gecko-based application which would use XUL.

>> maybe http://en.wikipedia.org/wiki/E4X
>> might be helpful. See for example https://developer.mozilla.org/en/E4X.

>
> i tried to set e4x in the script declaration, but it does not seem to
> change anything. And somewhere i read that it is not needed.


IIRC, it is no longer needed for recent versions of Firefox.

>> E4X is merely a syntax extension. It does _not_ *createfiles*, neither
>> does document.write(). If you were talking about server-side scripting,
>> then E4X might be an option for efficiently writing the data with e.g.
>> write(). But you would still need a host object (e.g.File) to do it.

>
> So you mean, I should create a file, which will be used to write on
> data temporarily.


I do not know yet what exactly you want to accomplish, so I have not made
any recommendation yet.

> Then if I guess I have to allocate some space for its potential size,
> right? How can i do that?


Try to clarify what you are trying to accomplish before jumping to further
conclusions.

>> > i would like something of theform
>> > - create new file of name "newfile.xml"
>> > - write "anything" in "newfile.xml"

>>
>> As this requires the use of host objects, it is nearly impossible to say
>> without you stating your requirements, especially the target runtime
>> environments.

>
> Well, I understand that an user that uses a web site for some
> calculations cannot have the permission to write in the server that
> hosts the web site.


That is incorrect if "write in the server" means "write access to the
server's filesystem". A user can be granted restricted access to certain
areas of that filesystem if necessary.

> But what if the user had the permission to create a temporary file;


They already have: on the client-side, in memory, so to speak.

> then if he wants to save it in his hard disk, then he has the possibility
> to do it, otherwise the file would be deleted permanently. I believe there
> must be such a possibility,


Now we are finally talking. So you want the *user* to initiate the Save
operation? That can be arranged. Using DOM methods (but with XML, better
not document.write()) is the first step to a client-side solution, creating
a temporary document in memory (not a file), which can be saved as a file in
the user's local filesystem.

> it's only i don't know how to explain it better. Imagine some form you
> submit with your personal data. On submission, the data are processed
> somehow, but also the user has thew right to see what he filled in in
> this form.


But that is what *server-side* scripting has been devised for. Assuming you
want to store the submitted data somewhere on the server-side, you should
generate, with a server-side application, in the same process, an XML
document that contains the submitted data, and serve it via HTTP (either
automatically or on user request). Because you cannot be sure that the data
was successfully transmitted from the client side. How you would do it
would depend on your server-side environment.

>> well, concerning creating the file, you have a problem with creating any
>> new file from scratch. First decide what file you want ... if you mean
>> like real file on the local hard drive, then it is kind of complicated,
>> otherwise if you want a chunk of data formatted as XML send over the
>> wire somewhere, it is easy.

>
> I think that this is what i describe above, isn't it? Data formatted
> as xml sent saved in the user's hard disk,


Saving files, however, is usually something that only a user can do, on the
client-side. You/the server side can only provide the data to be saved.

> or sent to an email address.


That needs to be done from the server-side instead because you cannot assume
the user has a suitable e-mail client installed or, if installed, that you
could trigger it from the Web browser or another application.


PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Has thought been given given to a cleaned up C? Possibly called C+. Casey Hawthorne C Programming 385 04-04-2010 02:11 AM
" Given BACK what was freely GIVEN " 2Barter.net C++ 0 12-13-2006 02:56 AM
Days in a given date range for a given month......... Lord0 Java 1 04-19-2006 04:54 PM
generate all possible strings of given length given a set of characters chiara C Programming 6 10-06-2005 01:43 AM
ASP XML Support - Generate XML string from FORM DATA based on XML schema Matt ASP General 3 04-23-2004 07:12 PM



Advertisments