[Objective-c C#] XML字串轉成開發用字串

  • 994
  • 0

摘要:[Objective-c C#] XML字串轉成開發用字串

最近在寫Objectice-c接.NET的Webservice,即SOAP,每每要把那一堆SOAP字串改為Objective-c的字串很麻煩,所以寫了個小程式來轉換

https://docs.google.com/file/d/0Bznwsd34FjEPMTdhdThId3hlTkE/edit?usp=sharing

source code如下


//objective-c
private void button1_Click(object sender, EventArgs e)
{
	string data = textBox1.Text.Replace("\"","\\\"");
	textBox1.Text = data;
	string[] ary = data.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
	textBox1.Text = "@";
	foreach (string str in ary)
	{
		textBox1.Text = textBox1.Text +  string.Format("\"{0}\"{1}",str.TrimStart(),Environment.NewLine);
	}
	textBox1.Text = textBox1.Text.Remove(textBox1.Text.Length - 1);
	textBox1.Text += ";";
	
}
//c#
private void button2_Click(object sender, EventArgs e)
{
	string data = textBox1.Text;
	string[] ary = data.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
	textBox1.Text = "";
	foreach (string str in ary)
	{
		textBox1.Text = textBox1.Text + string.Format("\"{0}\" +{1}", str.TrimStart(), Environment.NewLine);
	}
	textBox1.Text = textBox1.Text.Remove(textBox1.Text.Length - 3);
	textBox1.Text += ";";
}