问题描述
我正在wcf中以网页中的xml形式获取信息,该值存储在一个字符串对象中.但是我没有那个xml文件名,只是从类中以xml的形式获取值,但是我需要从那读取xml节点的值..
posible.pls如何帮助我..感谢您在adv中....
i am getting the information as xml in a webpage in wcf that value stored in one string object. but i dont have that xml file name ,just iam getting values from class as xml,but i need to read that xml nodes values from that..
how it is posible.pls help me..thank u in adv ....
<boolean xmlns="http://schemas.microsoft.com/2003/10/Serialization/">true</boolean>
我将这个值放入一个字符串变量中,我只需要读取"true"的值...请帮助我....
i am getting this value into one string variable i need to read that value of "true" only...pls help me....
推荐答案
XDocument doc = XDocument.Parse(myString);
XElement root = doc.Element("rootElementName");
如果您只是获取xml数据(不带文件头),请使用以下命令:
If you''re just getting xml data (without the file header), use this:
XElement root = XDocument.Parse(myString);
之后,您可以进入节点.
编辑(在向我们展示了您要返回的数据之后)============
最简单的方法是执行以下操作:
After that, you can get to the nodes.
EDIT (after you showed us the data you''re getting back) ============
The easy way is to do this:
bool result = myString.ToLower().Contains(">true<");
当然,这仅适用于您的示例,并且有欺骗性,但可以完成工作.
Of course, this will only work for your example, and is cheating, but it gets the job done.
这篇关于WCF服务实现的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!