1

I try to read a value out of an xml-file.
I get the right line into a char[255] using fgets. When I try to extract the nodes content, the corresponding value doesn't get changed.

XML:

   \t<name>A fancy Name</name>

C++:

   ...
   char buff[255];
   fgets(buff,255,Filestream);
   scanf(buff,"\t<name>%[^<]</name>",&(Daten.name));

Daten.name is an UnicodeString (used by Embarcadero's c++-Builder) by the way. But Daten.name remains unchanged...

I also tried not using the pointer to Daten.name but the variable directly, but it doesn't seem to change anything...

Can you help me find my mistake here?

Julian
  • 493
  • 4
  • 22
  • 1
    Ouch. Please consider using a tool to parse XML for you: http://stackoverflow.com/questions/170686/best-open-xml-parser-for-c – Steve Wellens Jul 22 '14 at 13:56
  • why not use an [xml](http://rapidxml.sourceforge.net/manual.html) [library](http://pugixml.org/)? – Dmitry Ledentsov Jul 22 '14 at 13:57
  • Agree that you shouldn't do this in the first place. However - you should always check the return values from `fgets` and `scanf` ... – Useless Jul 22 '14 at 13:57
  • @SteveWellens, Dimitry, Useless: Well, I tried XMLDoc before, like it is explained here http://www.functionx.com/cppbuilder/xml/Lesson01.htm , but with all the childnode-findnode lines I need to use just to navigate where I want, it seems a lot more complicated than using it as text-file where it's devided by line-separators... anyway, do you have an idea why the scanf-format isn't matching here? – Julian Jul 22 '14 at 14:07

0 Answers0