Jump to content

Dynamically create xml file with echo command


Recommended Posts

Hi guys,

once again, a problem with cmd commands :-) If anyone has a solution, I would very much appreciate it ...

Here´s the problem:

I need to dynamically create an xml file with a commandline script so I was thinking of using the ECHO command to create that script something like:

ECHO This text goes to the new file >C:\Test.xml
ECHO Next line >>C:\Test.xml

Only problem is ... the xml file has symbols in the text that ECHO interprets as commands.

Example: this line should go into the xml:

<?xml version="1.0" encoding="utf-8"?>

Now, how do I do that ? Iif I wrap the whole code into double quotes like this:

ECHO "<?xml version="1.0" encoding="utf-8"?>" >C:\Test.xml

the quotes get written into the xml like this:

"<?xml version="1.0" encoding="utf-8"?>"

If I don´t do that, ECHO interprets the "<" and ">" symbols as commands and throws an error message.

If I use single quotes instead of double quotes, the whole code gets messed up even more. I also tried adding a "\" before the double quotes but this does not help either.

Since the whole thing is part of a bigger cmd script, it should not be vbscript or anything else.

Does anyone have an idea ??

Thanks for your help!

Alex

Link to comment
Share on other sites


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...