0

I have an xml file whose contents are

<Body>
      <Head1>Some Heading</Head1>
      <Body1>
             <K1>V1</K1>
             <K2>V2</K2>
      </Body1>
</Body>

when I read this file into a buffer(which is a char array in C) using fread similar to this code: Reading the whole text file into a char array in C I obtain a c buffer which contain whitespace. is there a way the additional whitespace which are coming on the left in the XML file be removed by loading into the buffer?

EDIT: I earlier used fgets to read the file line by line, removed the whitespaces on the left and concatenated. it worked, but is there a better way?

Community
  • 1
  • 1
Mohit
  • 891
  • 10
  • 25
  • 3
    You might consider using an [xml parser library](http://stackoverflow.com/questions/399704/xml-parser-for-c) and not worry about extra spaces. – 001 Jun 12 '14 at 13:46
  • 1
    why invent the wheel a second time? use libxml2 and all is done for you. programming is about reusage – Peter Miehle Jun 12 '14 at 14:02

0 Answers0