如何从输出xml文档中删除NewDataSet标签​​? [英] how to remove NewDataSet tag from output xml document?

查看:151
本文介绍了如何从输出xml文档中删除NewDataSet标签​​?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在输出中我有那个新的数据集标签.我必须删除此标签
当前输出是

in the output i am having that new dataset tag.I have to remove this tag
the current output is

<NewDataSet>
<Table>
</Table>
<Table>
</Table>
...
</NewDataSet>


但是我需要以下格式的输出


But i need the output in the following format

<Table>
</Table>
<Table>
</Table>


因为当客户端使用其SOAP UI工具对我的Web服务输出进行加载时,此NewDataset会创建一个空白节点,如< newdataset xmlns =">.
这会导致通过Web服务导入数据的问题.
现在,我必须从末端删除NewDataset标签.
检查以下代码:


Because when client is loadind my web service output with their SOAP UI tool this NewDataset creats one blank node like <newdataset xmlns="">.
This causes problem to import the data through web service.
Now i have to remove the NewDataset tag from my end.
check the below code:

string temp1 = DS.GetXml();//DS is dataset
           myDatas.LoadXml(temp1);
           string temp = myDatas.FirstChild.InnerXml;
           XmlNode node = myDatas.ParentNode;
           myDatas1.LoadXml(temp);


但是问题是Load xml仅适用于单个


But the problem is that Load xml works for only single

<Table></Table>

..否则它会引发多个根错误..请帮助我解决这个问题..请尝试处理新的数据集!

..else it throws multiple root error..please help me in this problem..wht to do with that new dataset thing!

推荐答案

问题是,当您遵循XML规则时,必须具有单个根元素.但是,当您真的想丢失它时,最直接的方法是替换</NewDataSet>"和< NewDataSet>"和 "".最好使用IndexOf和LastIndexOf之类的方法将其删除.

http://msdn.microsoft.com/en-us/library/7wtc81z6.aspx [ ^ ]

祝你好运!
The problem is that when you follow XML rules it is mandatory to have a single root element. But when you would really like to lose it, the most straight way would be to replace "</NewDataSet>" and "<NewDataSet>" with "". It would be better to use methods like IndexOf and LastIndexOf to remove it.

http://msdn.microsoft.com/en-us/library/7wtc81z6.aspx[^]

Good luck!


这篇关于如何从输出xml文档中删除NewDataSet标签​​?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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