2013-04-23 35 views

回答

0

也许最简单的方法是使用string.Split方法。

6

您可以尝试解析XML:

XElement.Parse(str).Value 
+0

'var str = @“ m48333189002”;' – Romoku 2013-04-23 12:52:27

+0

尼斯。切勿试图用substring,splitting或regexes自己解析xml。 – Corak 2013-04-23 12:54:12

+0

+1,简单而正确 – Habib 2013-04-23 12:54:21

0

我想你希望像下面,

进口:

using System.Xml; 
using System.Xml.Linq; 

代码:

string xmlResult = "<string xmlns=\"http://schemas.microsoft.com/2003/10/Serialization/\">m48333189002</string>";  
// place the sample result into a stream 
ASCIIEncoding encoding = new ASCIIEncoding(); 
byte[] xmlBytes = encoding.GetBytes(xmlResult); 
// create a stream from the byte array 
MemoryStream ms = new MemoryStream(xmlBytes); 
// read and deserialize the xml 
XmlTextReader respXmlRdr = new XmlTextReader(ms); 
// Linq to XML to extract return value from namespace decorated 
// return XML string 
XDocument xDoc = XDocument.Load(respXmlRdr); 
string Result = xDoc.Root.Value; 
Console.WriteLine(Result);