Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML in DOS

Status
Not open for further replies.

txgeekgirl1

Programmer
Sep 10, 2009
85
US
I really don't know if I can get any help but here it is.... I have a .UXML file that I have to rewrite in a batch file to create permissions files on the fly. My problem is - how do I get around the special characters that also have DOS connotations?

Code:
ECHO <?xml version="1.0" encoding="utf-8"?> >C:\Docume~1\blahblahblah\userPref.UXML

 
In a batch file or at console, like this.
[tt] ECHO [red]^[/red]<?xml version="1.0" encoding="utf-8"?[red]^[/red]> >C:\Docume~1\blahblahblah\userPref.UXML
[/tt]
 
Thanks tsuji -

Any idea why after 2 lines it stops writing? I have about 50 lines to write...

Code:
C:

ECHO ^<?xml version="1.0" encoding="utf-8"?>^ > c:\myfile.uxml
ECHO ^<UserPreferanceXML xmlns:xsi="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema-instance"[/URL] xmlns:xsd="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema">^[/URL] >> c:\myfile.uxml
ECHO ^<ShowToolbarImage>true</ShowToolbarImage>^ >> c:\myfile.uxml
ECHO ^<ShowToolbarText>false</ShowToolbarText>^ >> c:\myfile.uxml
 
[1] First >> has special meaning, just like > has. And then < has special meaning as well. If you want echo either > or < without that special meaning for the dos shell, you need to escape it appending ^ in front of it.

[1.1] The position of ^ is already mis-positioned in your second post.

[2] Watch out also line-break. It is not recognized by the shell and is taken as the limit for the echo internal command. There is no line-break in front of xmlns:xsd. If you want a line break, you put up another line and re-direction of the output to file.

[3] Watch carefully.
[tt]
ECHO ^<?xml version="1.0" encoding="utf-8"?^> > c:\myfile.uxml
ECHO ^<UserPreferanceXML xmlns:xsi="[ignore][/ignore]"
xmlns:xsd="[ignore][/ignore]"^> >> c:\myfile.uxml
ECHO ^<ShowToolbarImage^>true^</ShowToolbarImage^> >> c:\myfile.uxml
ECHO ^<ShowToolbarText^>false^</ShowToolbarText^> >> c:\myfile.uxml
[/tt]
 
Wanted to thank you once again. It worked perfectly once I understood the necessity of the ^ and it's placement inside the XML code.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top