0

I'm trying to insert data from a form in VC++ 2010 using pugiXML.

The issue is that whenever I try to enter the data, I get this error:

Error   1   error C2664: 'pugi::xml_node::set_value' : cannot convert parameter 1 from 'System::String ^' to 'const pugi::char_t *'

The code I'm using to insert the data is this:

descr.append_child().set_value(eClass->Text);

The documentation states that these functions accept string parameters, so I'm not sure why I'm getting an "expected char_t" error.

Justin
  • 93
  • 1
  • 11

2 Answers2

1

You seem to be trying to pass a

System::String

to pugixml. This string is not a char *, but a CLR string. You need to use

PtrToStringChars() 

to access the actual content and pin the string.

Take a look here on how to pass its contents to a function that accepts char * or wchar_t *.

DNT
  • 2,356
  • 14
  • 16
0

Did you try convert the string to char* ?

descr.append_child().set_value(eClass->Text.c_str());

Nyufu
  • 1