CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2008
    Posts
    59

    Post to read a .xml file

    In my program,I have to read the contents from a file(.map.xml) by line by line.
    While I tried it by copying it to a CStringlist, the data got end on each spaces... But I have to read it on line by line.Is thr any way to trim it?
    Plz get me code..

  2. #2
    Join Date
    Aug 1999
    Location
    <Classified>
    Posts
    6,882

    Re: to read a .xml file

    Why can't you just use Microsoft XML parser ?
    Regards,
    Ramkrishna Pawar

  3. #3
    Join Date
    Oct 2008
    Posts
    59

    Re: to read a .xml file

    Nop...

    because, in my program-to add a new feature,I wanna take some parts of data from a xml file... Every time,when the program runs the xml file will not be same..So the user should download the xml file which he want to run. tats wy-as a programmer-I need this file to open and read..

    So plz tell me a suit form to open n readthis xml file till end of line..(better I shd read line by line format)..... Help me plz.
    Arun

  4. #4
    Join Date
    Feb 2006
    Location
    Croatia - Zagreb
    Posts
    459

    Re: to read a .xml file

    I'm not sure what you want to do exactly.
    You will eventually need to parse the xml code, wouldn't you?

    But you can always use fread to read to a stream from a file.
    for example:
    Code:
      result = fread (buffer,1,size,file);
    You can also use this example to read file into a stream
    http://www.cplusplus.com/reference/c...dio/fread.html
    You just divided by zero, didn't you?

  5. #5
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: to read a .xml file

    Quote Originally Posted by arunkr6
    Nop...

    because, in my program-to add a new feature,I wanna take some parts of data from a xml file... Every time,when the program runs the xml file will not be same..So the user should download the xml file which he want to run. tats wy-as a programmer-I need this file to open and read..

    So plz tell me a suit form to open n readthis xml file till end of line..(better I shd read line by line format)..... Help me plz.
    Arun
    You still should use the Xml parser to read the file. After all, that's what an xml parser does - it reads xml. It really shouldn't matter what the xml contains because as long as it's valid xml, the parser is going to be able read it better than your hand written code.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured