Jump to content
Strawberry Orange Banana Lime Leaf Slate Sky Blueberry Grape Watermelon Chocolate Marble
Strawberry Orange Banana Lime Leaf Slate Sky Blueberry Grape Watermelon Chocolate Marble

MSFN is made available via donations, subscriptions and advertising revenue. The use of ad-blocking software hurts the site. Please disable ad-blocking software or set an exception for MSFN. Alternatively, register and become a site sponsor/subscriber and ads will be disabled automatically. 


midiboy

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

Share this post


Link to post
Share on other sites

Hi again,

ah, I should have looked up Technet before posting here, sorry :whistle:

The solution is to add a "^" before each ">" or "<".

:hello:

Bye,

Alex

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...