using System.Text.RegularExpressions;
public static void Main(string[] args)
Console.WriteLine ("Hello Mono World");
string rr = "<?xml version=\"1.0\" encoding=\"utf-8\"?> <comm> <state>INIT</state> <operator>dev06</operator> <incident>92</incident> <location>6797 ابن ماجة، السلي، الرياض 14266 2580، السعودية</location> <city>الرياض</city> <stateprov>منطقة الرياض</stateprov> <zippostal>14266</zippostal> <callback>0558995323</callback> <latitude>24.6687413399139</latitude> <longitude>46.8325281143188</longitude> <callphonetype>2</callphonetype> <callername>يزيد</callername> </comm> <?xml version=\"1.0\" encoding=\"UTF-8\" ?> <comm> <state>DISPATCH</state> <operator>dev06</operator> <incident>92</incident> <location>6797 ابن ماجة، السلي، الرياض 14266 2580، السعودية</location> <city>الرياض</city> <stateprov>منطقة الرياض</stateprov> <zippostal>14266</zippostal> <callback>0558995323</callback> <callername>يزيد</callername> <problem>غرق مريض في مسبح</problem> <party>0</party> <patients>1</patients> <agenum>55</agenum> <ageunit>Years</ageunit> <gender>Male</gender> <conscious>0</conscious> <breathing>0</breathing> <chiefcomplaint>14</chiefcomplaint> <chiefcomplainttext>غرق / على وشك الغرق / غطس / حادثة غوص</chiefcomplainttext> <dispatchlevel>14D06</dispatchlevel> <dispatchsuffix>D</dispatchsuffix> <cadresponse>Delta</cadresponse> <cadcode>14D06D</cadcode> <latitude>24.6687413399139</latitude> <longitude>46.8325281143188</longitude> <responsescript> <script> <determinanttext>إصابة مشتبه بها في منطقة الرقبة</determinanttext> <suffixtext>إصابة غطس (ليس تحت الماء)</suffixtext> <cmds4>55 سنة, ذكر, واعي, يتنفس.</cmds4> <chiefcomplainttext>غرق / على وشك الغرق / غطس / حادثة غوص</chiefcomplainttext> <problem>غرق مريض في مسبح</problem> </script> <keyquestions> <question seq=\"1\" qt=\"1\" kqai=\"1\" answerid=\"54820\">انه خارج المياه و ليس في خطر.</question> <question seq=\"2\" qt=\"3\" kqai=\"1\" answerid=\"56244\">يعاني من إصابة غطس.</question> <question seq=\"3\" qt=\"0\" kqai=\"2\" answerid=\"54659\">أنه يعاني من إصابة مشتبه بها في منطقة الرقبة.</question> <question seq=\"4\" qt=\"7\" kqai=\"2\" answerid=\"54683\">أنه منتبه تماماً (يستجيب بطريقة طبيعية).</question> <question seq=\"5\" qt=\"7\" kqai=\"2\" answerid=\"54708\">أنه يتنفس بشكل طبيعي.</question> </keyquestions> <shortkeyquestions> <question seq=\"1\" qt=\"1\" kqai=\"1\" answerid=\"54820\">خارج المياه – ليس في خطر.</question> <question seq=\"2\" qt=\"3\" kqai=\"1\" answerid=\"56244\">أصابة غطس</question> <question seq=\"3\" qt=\"0\" kqai=\"2\" answerid=\"54659\">--== Element 22669 Does Not Exist ==--</question> <question seq=\"4\" qt=\"7\" kqai=\"2\" answerid=\"54683\">--== Element 22098 Does Not Exist ==--</question> <question seq=\"5\" qt=\"7\" kqai=\"2\" answerid=\"54708\">--== Element 22032 Does Not Exist ==--</question> </shortkeyquestions> <filteredkeyquestions> <question seq=\"3\" qt=\"0\" kqai=\"2\" answerid=\"54659\">أنه يعاني من إصابة مشتبه بها في منطقة الرقبة.</question> <question seq=\"1\" qt=\"1\" kqai=\"1\" answerid=\"54820\">انه خارج المياه و ليس في خطر.</question> <question seq=\"2\" qt=\"3\" kqai=\"1\" answerid=\"56244\">يعاني من إصابة غطس.</question> <question seq=\"4\" qt=\"7\" kqai=\"2\" answerid=\"54683\">أنه منتبه تماماً (يستجيب بطريقة طبيعية).</question> <question seq=\"5\" qt=\"7\" kqai=\"2\" answerid=\"54708\">أنه يتنفس بشكل طبيعي.</question> </filteredkeyquestions> <summary>55 سنة, ذكر, واعي, يتنفس. غرق / على وشك الغرق / غطس / حادثة غوص الرمز: •14-D-6-D: إصابة مشتبه بها في منطقة الرقبة (إصابة غطس (ليس تحت الماء)) تصريح المتصل: غرق مريض في مسبح. 1. انه خارج المياه و ليس في خطر. 2. يعاني من إصابة غطس. 3. أنه يعاني من إصابة مشتبه بها في منطقة الرقبة. 4. أنه منتبه تماماً (يستجيب بطريقة طبيعية). 5. أنه يتنفس بشكل طبيعي.</summary> </responsescript> </comm> <?xml version=\"1.0\" encoding=\"utf-8\"?> <comm> <state>INIT</state> <operator>dev06</operator> <incident>104</incident> <location>7943 الامير جلوي بن تركي بن عبدالله حي الملك فهد الرياض 12273 - 2587</location> <city>الرياض</city> <stateprov>منطقة الرياض</stateprov> <zippostal>12273</zippostal> <callback>0558995323</callback> <latitude>24.746831298412</latitude> <longitude>46.6644287109375</longitude> <callphonetype>2</callphonetype> <callername>يزيد</callername> </comm> <?xml version=\"1.0\" encoding=\"UTF-8\" ?> <comm> <state>ENDCE</state> <operator>dev06</operator> <incident>SQ-615</incident> <problem>غير واعي تجريبي</problem> <party>0</party> <patients>1</patients> <agenum>30</agenum> <ageunit>Years</ageunit> <gender>Male</gender> <conscious>1</conscious> <breathing>1</breathing> <chiefcomplaint>9</chiefcomplaint> <chiefcomplainttext>توقف في القلب او التنفس / موت</chiefcomplainttext> <responsescript> <script> <cmds4>30 سنة, ذكر, غير واعي, لا يتنفس.</cmds4> <chiefcomplainttext>توقف في القلب او التنفس / موت</chiefcomplainttext> <problem>غير واعي تجريبي</problem> </script> <summary>30 سنة, ذكر, غير واعي, لا يتنفس. توقف في القلب او التنفس / موت تصريح المتصل: غير واعي تجريبي.</summary> </responsescript> </comm> <?xml version=\"1.0\" encoding=\"UTF-8\" ?> <comm> <state>NEWCASENO</state> <incident>3964</incident> </comm> <?xml version=\"1.0\" encoding=\"UTF-8\" ?> <comm> <state>ENDCE</state> <incident>3964</incident> <dispatchlevel>09E01</dispatchlevel> <overincident>3964</overincident> <cadresponse>ALS/BLS HOT</cadresponse> <cadcode>9E01</cadcode> </comm> <?xml version=\"1.0\" encoding=\"UTF-8\" ?> <comm> <state>ENDKQ</state> <incident>3964</incident> <dispatchlevel>09E01</dispatchlevel> <overincident>3964</overincident> <cadresponse>ALS/BLS HOT</cadresponse> <cadcode>9E01</cadcode> <responsescript> <keyquestions> <question seq=\"1\" qt=\"3\" kqai=\"1\" answerid=\"55243\">التوقف في القلب مشهود او حدث للتو.</question> <question seq=\"2\" qt=\"7\" kqai=\"2\" answerid=\"55030\">جهاز الصدمة الكهربائية (AED) غير متوفر.</question> </keyquestions> <shortkeyquestions> <question seq=\"1\" qt=\"3\" kqai=\"1\" answerid=\"55243\">توقف في القلب مشهود/حدث للتو.</question> <question seq=\"2\" qt=\"7\" kqai=\"2\" answerid=\"55030\">--== Element 22357 Does Not Exist ==--</question> </shortkeyquestions> <filteredkeyquestions> <question seq=\"1\" qt=\"3\" kqai=\"1\" answerid=\"55243\">التوقف في القلب مشهود او حدث للتو.</question> <question seq=\"2\" qt=\"7\" kqai=\"2\" answerid=\"55030\">جهاز الصدمة الكهربائية (AED) غير متوفر.</question> </filteredkeyquestions> <summary>1. التوقف في القلب مشهود او حدث للتو. 2. جهاز الصدمة الكهربائية (AED) غير متوفر.</summary> </responsescript> </comm> <?xml version=\"1.0\" encoding=\"UTF-8\" ?> <comm> <state>COMPLETE</state> <incident>3964</incident> <dispatchlevel>09E01</dispatchlevel> <overincident>3964</overincident> <cadresponse>ALS/BLS HOT</cadresponse> <cadcode>9E01</cadcode> <conditioncode>ALS Hot</conditioncode> </comm> <?xml version=\"1.0\" encoding=\"UTF-8\" ?> <comm> <state>WAITING</state> <operator>ywaheaid</operator> <incident>SQ-158454</incident> </comm>";
HelloWorld.ProcessResponse(rr);
public static void ProcessResponse(string response)
string extraResponse = null;
if (Regex.Matches(response, "</comm>").Count > 1)
var splitPoint = response.IndexOf("</comm>") + 7;
extraResponse = response.Substring(splitPoint);
response = response.Substring(response.IndexOf("<"), splitPoint);
Console.WriteLine(ex.Message);
response = (response.StartsWith("<"))? response : response.Substring(response.IndexOf("<"));
Console.WriteLine(ex.Message);
Console.WriteLine("Response: \n" + response);
Console.WriteLine("\nExtra response: \n" + extraResponse);
Console.WriteLine("\n ***************************************** ");
if(!string.IsNullOrEmpty(extraResponse))
HelloWorld.ProcessResponse(extraResponse);