Hola amigos.
Tengo una funcion en C que me muestra en consola el perfil wireless que yo le indique, hasta aqui todo bien. El problema esta en que recibo los datos en ese formato:
<?xml version="1.0"?>
<WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1">
<name>NombrePerfil</name>
<SSIDConfig>
<SSID>
<hex>75775657685794438794</hex>
<name>NombrePerfil</name>
</SSID>
</SSIDConfig>
<connectionType>ESS</connectionType>
<MSM>
<security>
<authEncryption>
<authentication>WPA2PSK</authentication>
<encryption>AES</encryption>
<useOneX>false</useOneX>
</authEncryption>
<sharedKey>
<keyType>passPhrase</keyType>
<protected>false</protected>
<keyMaterial>1234567890</keyMaterial>
</sharedKey>
<keyIndex>1</keyIndex>
</security>
</MSM>
</WLANProfile>
Entonces necesitaria una funcion que extraiga los datos que hay entre <name> y </name>, <connectionType> y </connectionType> y asi con todos los valores.
Quedaria algo asi en consola:
Nombre del perfil: NombrePerfil
Tipo de conexion: ESS
Aunenicacion: WPA2PSK
etc..
Aclaracion: los datos no los recibo de un archivo, sino del PC, de los perfiles almacenados en la WLAN con esta llamada:
hp = Device->GetProfile(ARRAYSIZE(profBuffer), profBuffer);
He probado con este codigo que vi por inernet, pero se bloquea la aplicacion y se termina (creo que se bloquea porque es codigo de C++ y al tratar de usarlo en C se bloquea, no lo se):
int size = 0;
wchar_t* Perfil = profBuffer;
std::string text(Perfil, Perfil + size);
// define what we're looking for
std::string begin_text("<name>");
std::string end_text("</name>");
// find the start and end of the text we need to extract
size_t begin_pos = text.find(begin_text) + begin_text.length();
size_t end_pos = text.find(end_text);
// create a substring from the positions
std::string extract = text.substr(begin_pos,end_pos);
// test that we got the extract
wprintf(L"\nINFO: Nombre del perfil: ", extract);
Espero que me puedan ayudar. Saludos!!