<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">m48333189002</string>
如何从此字符串之间访问值m48333189002?如何访问特定值之间以特定方式格式化的字符串c#
请帮
<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">m48333189002</string>
如何从此字符串之间访问值m48333189002?如何访问特定值之间以特定方式格式化的字符串c#
请帮
也许最简单的方法是使用string.Split方法。
我想你希望像下面,
进口:
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);
这是一个一次性字符串,还是较大文件的一部分? – 2013-04-23 12:46:40
one string ......... – vini 2013-04-23 12:47:09