将xml转换为纯字符串 [英] Convert xml to pure string

查看:46
本文介绍了将xml转换为纯字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将类对象序列化为字符串.但它从下面的代码中以 xml 的形式给出输出.

I am trying to serialize the class object to string. But it is giving output in the form of xml from the below code.

Dim x As New Xml.Serialization.XmlSerializer(response.GetType)
Dim sw As New IO.StringWriter()
x.Serialize(sw, response)
Return sw.ToString

电流输出

<Employees>
<Employee>John</Employee>
<Employee>Peter</Employee>
</Employees>

预期输出

<Employees><Employee>John</Employee><Employee>Peter</Employee></Employees>

推荐答案

不要将响应文本转换为 XML 对象,将其保留为字符串.

Don't convert the response text into an XML object, keep it as a string.

从那里这篇帖子应该很有启发性.一旦这一切都说完并存储在一个变量中,您就可以执行所有 XML 序列化您的心愿了.

From there this post should be enlightening. Once that's all said and done and stored in a variable, you can do all the XML serializing your heart desires.

这篇关于将xml转换为纯字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆