I have this below XML response . I need to store each node and its value in a array and the attach the array in the URL as querystring and redirect to a diferrent page . Please help
<responseId>76</responseId>
<status>SUCCESS</status>
<result>
<reference_number>FA002900118</reference_number>
<remitter_id>10023</remitter_id>
<remitter_name>TEST SACCO</remitter_name>
<beneficiary_id>9</beneficiary_id>
<beneficiary_name>KENYA USA DIASPORA SACCO LTD</beneficiary_name>
<trans_type>Account</trans_type>
<destination_country>Kenya</destination_country>
<source_currency>USD</source_currency>
<source_transfer_amount>10.00</source_transfer_amount>
<rate>83.4000</rate>
<destination_currency>KES</destination_currency>
<destination_amount>834.00</destination_amount>
<commission>5.00</commission>
<agent_fee>0.00</agent_fee>
<hq_fee>0.00</hq_fee>
<remitter_pay_amount>15.00</remitter_pay_amount>
<agent_deduction>2.50</agent_deduction>
<agent_to_pay_hq>12.50</agent_to_pay_hq>
<delivery_date>2012-12-07 00:00:00-05</delivery_date>
<payment_token>3954d4d87aa2926dbb6150658881ec4622b101b6</payment_token>
</result>
I have somehow reached to some code to get the output with some delimiter but still confused how to put the same in an array and paas it as querystring to next page
string str = “”;
XmlTextReader reader = new XmlTextReader("D:/TempXml.Xml");
while (reader.Read())
{
XmlNodeType nodeType = reader.NodeType;
switch (nodeType)
{
case XmlNodeType.Element:
str+= " Element - " + reader.Name + ";";
if (reader.HasAttributes)
{
for (int i = 0; i < reader.AttributeCount; i++)
{
reader.MoveToAttribute(i);
str+= "Attribute - " + reader.Name + reader.Value;
}
}
break;
case XmlNodeType.Text:
str += " Value - " + reader.Value + ";";
break;
}
}
Label1.Text = str;
output
Element – response; Element – responseId; Value – 76; Element – status; Value – SUCCESS; Element – result; Element – reference_number; Value – FA002900118; Element – remitter_id; Value – 10023; Element – remitter_name; Value – TEST SACCO; Element – beneficiary_id; Value – 9; Element – beneficiary_name; Value – KENYA USA DIASPORA SACCO LTD; Element – trans_type; Value – Account; Element – destination_country; Value – Kenya; Element – source_currency; Value – USD; Element – source_transfer_amount; Value – 10.00; Element – rate; Value – 83.4000; Element – destination_currency; Value – KES; Element – destination_amount; Value – 834.00; Element – commission; Value – 5.00; Element – agent_fee; Value – 0.00; Element – hq_fee; Value – 0.00; Element – remitter_pay_amount; Value – 15.00; Element – agent_deduction; Value – 2.50; Element – agent_to_pay_hq; Value – 12.50; Element – delivery_date; Value – 2012-12-07 00:00:00-05; Element – payment_token; Value – 3954d4d87aa2926dbb6150658881ec4622b101b6;
Use next code you can get
ListofKeyValuePair, where key is tag name and value is tag content text:i think you can create query string form list.
For redirect to other page in ASP.NET you can use
HttpResponce.Redirect(more info http://msdn.microsoft.com/en-us/library/t9dwyts4.aspx)