How to write given Text into a xml file?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Xintaur
Posts: 2
Joined: 27 Oct 2016 13:52

How to write given Text into a xml file?

#1 Post by Xintaur » 27 Oct 2016 14:08

Hello Guys,
i need some help with this line in my code:

echo <text>text:\text\</text> > file.xml

Like that it simply gives error.

echo ^<text>text:\text\</text>^ > file.xml

This does almost work, but now it tells me, that it cant find the selected path and i dont know how to fix that.
I need this for Gamecode, so i cant change the structure of the text above and the problem is not the xml file, since i tried it without that parameter.
Sry for my bad english, its not my first language ^^

penpen
Expert
Posts: 2009
Joined: 23 Jun 2013 06:15
Location: Germany

Re: How to write given Text into a xml file?

#2 Post by penpen » 27 Oct 2016 19:10

The reason is that the lower-than and greater-than characters ('<', '>') are special characters which that you can redirect the output to a file:

Code: Select all

>"test.txt" echo Hello "text.txt"!

The solution is easy.
You have noticed the circumflex accent character ('^') is an escape character, that "disables" the ability of the next character to behave like a special character, so just use it before any of the special characters above:

Code: Select all

>"file.xml" echo ^<text^>text:\text\^</text^>


penpen

Xintaur
Posts: 2
Joined: 27 Oct 2016 13:52

Re: How to write given Text into a xml file?

#3 Post by Xintaur » 30 Oct 2016 13:06

penpen wrote:The reason is that the lower-than and greater-than characters ('<', '>') are special characters which that you can redirect the output to a file:

Code: Select all

>"test.txt" echo Hello "text.txt"!

The solution is easy.
You have noticed the circumflex accent character ('^') is an escape character, that "disables" the ability of the next character to behave like a special character, so just use it before any of the special characters above:

Code: Select all

>"file.xml" echo ^<text^>text:\text\^</text^>


penpen


Thx for answering :D Works great that way.

Post Reply