I wanna do something but i dont have idea how. Myxml looks like this
<Person xmlns="http://askmk/ask/ReportTypes">
<PersonObjectId>11111111</PersonObjectId>
<CellPhoneNo>070220750 </CellPhoneNo>
<DateOfBirth>1971-03-06</DateOfBirth>
<Email>[email protected] </Email>
<EMBG>00000000000</EMBG>
<IsResident>1</IsResident>
<FirstName>XXX</FirstName>
<GenderTypeId>3</GenderTypeId>
<LastName>XXX</LastName>
<PhoneNo />
<PlaceOfBirth />
<IdDocumentList>
<IdDocument>
<IdDocumentTypeId>2</IdDocumentTypeId>
<PlaceOfIssue>XXXX</PlaceOfIssue>
<IdNo>XXX</IdNo>
</IdDocument>
</IdDocumentList>
</Person>
With this code written down, i am good but not the way i need it.
XmlDocument doc = new XmlDocument();
doc.Load(path);
string test = doc.InnerXml.ToString();
var xDoc = XDocument.Parse(test);
XmlNamespaceManager mgr = new XmlNamespaceManager(xDoc.CreateNavigator().NameTable);
mgr.AddNamespace("ns", "http://askmk/ask/ReportTypes");
var dict = xDoc.XPathSelectElement("//ns:Person", mgr) .Elements() .ToDictionary(a => a.Name.LocalName, a => a.Value);
With this code the value of dict is
[0] {[PersonObjectId, 11111111]} System.Collections.Generic.KeyValuePair<string, string>
[1] {[CellPhoneNo, 070220750 ]} System.Collections.Generic.KeyValuePair<string, string>
[2] {[DateOfBirth, 1971-03-06]} System.Collections.Generic.KeyValuePair<string, string>
[3] {[Email, [email protected] ]} System.Collections.Generic.KeyValuePair<string, string>
[4] {[EMBG, 0000000000]} System.Collections.Generic.KeyValuePair<string, string>
[5] {[IsResident, 1]} System.Collections.Generic.KeyValuePair<string, string>
[6] {[FirstName, XXX]} System.Collections.Generic.KeyValuePair<string, string>
[7] {[GenderTypeId, 3]} System.Collections.Generic.KeyValuePair<string, string>
[8] {[LastName, XXX]} System.Collections.Generic.KeyValuePair<string, string>
[9] {[PhoneNo, ]} System.Collections.Generic.KeyValuePair<string, string>
[10] {[PlaceOfBirth, ]} System.Collections.Generic.KeyValuePair<string, string>
[11] {[IdDocumentList, XXXX XXX]}
What i want to change here is the 11th node, and i want it to be replaced with the nodes inside it. I want
[11] {[IdDocumentList, XXXX XXX]}
to be replaced with
[11]{[IdDocumentTypeId,2]}
[12]{[PlaceOfIssue,XXXX]}
[13]{[IdNo,XXX]}
Can someone point me on how to do it?