Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Edit xml File with fopen and fprintf
Replies: 4   Last Post: Dec 25, 2012 11:32 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Avri Alony

Posts: 40
Registered: 1/22/11
Edit xml File with fopen and fprintf
Posted: Dec 25, 2012 4:57 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

I have xml file with few strings rows
I used fopen to open the original file, fopen('w') to open new file and fprintf to print all line from original file to new file as one can see below.

The problem is that when I open the new file with notepad I get messy text, instead of rows I get long text with spaces
when I open it with notepad++ then the text is organize by rows exactly as in the original file.

Which function I shall use in order to get exactly the same text structure?

Function Code:

FidOldFile = fopen([PathName,'\',FileName]);
FidNewFile = fopen([PathName,'\',NewFileName],'w');
tline = fgetl(FidOldFile);
while ischar(tline)
fprintf(FidNewFile,'%s\n',tline);
tline = fgetl(FidOldFile);
end



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.