how i can take a part of this string :
string="<ArrayOfArrayOfKeyValueOfstringstring xmlns:d1p1="http://www.w3.org/2001/XMLSchema" i:type="d1p1:base64Binary" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays">0RuHA6OkPMP7myQPAR4ZDMoB8mo=</ArrayOfArrayOfKeyValueOfstringstring>";
i need to take just this part "0RuHA6OkPMP7myQPAR4ZDMoB8mo" , how can i programmaticaly divide the part i need?
its not an xml its the string the system give me back when i ask details of the telephone, i need to get only the part of the IMEI:
Object obj = DeviceExtendedProperties.GetValue("DeviceUniqueId");
byte[] objByte = ObjectToByteArray(obj);
IMEI = System.Text.Encoding.UTF8.GetString(objByte, 0, objByte.Length);
this the ObjectToByteArray():
private byte[] ObjectToByteArray(Object obj)
{
DataContractSerializer serializer = new DataContractSerializer(typeof(List<Dictionary<String, String>>));
byte[] byteArr;
using (var ms = new System.IO.MemoryStream())
{
serializer.WriteObject(ms, obj);
byteArr = ms.ToArray();
}
return byteArr;
i cut the string using Split and Replace by this way:
a1 = IMEI.Split(IMEIerrato, 2 ,StringSplitOptions.None);
IMEIgiusto = a1[1].Replace("=</ArrayOfArrayOfKeyValueOfstringstring>", "");
Debug.WriteLine("IMEI: "+IMEIgiusto);
i get this output:
IMEI: 0RuHA6OkPMP7myQPAR4ZDMoB8mo
RESOLVED
I'd use an XML API:
XElement element = XElement.Parse(text);
string value = element.Value;
byte[] bytes = Convert.FromBase64String(value);
See more on this question at Stackoverflow