删除不需要的XML行 [英] Remove Unwanted Line of XML

查看:81
本文介绍了删除不需要的XML行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的专家



i想删除一行xml。



我的xml如下:



Dear expert

i want to remove a line of xml.

my xml like this :

POST / HTTP/1.1
Host: 192.168.0.21:2010
Content-Length: 725
Connection: Keep-Alive

<?xml version="1.0"?>
<Metrics SiteId="Company 1" Sitename="Lokasi 1" DeviceId="Device1" Devicename="Device_1">
<Properties>
<MacAddress>00:b0:9d:c8:ab:9b</MacAddress>
<IpAddress>192.168.0.123</IpAddress>
<HttpPort>80</HttpPort>
<HttpsPort>443</HttpsPort>
<HostName>Cam-13151131</HostName>
<HwPlatform>1100</HwPlatform>
<Timezone>7</Timezone>
<DST>0</DST>
<DeviceType>0</DeviceType>
<SerialNumber>13151131</SerialNumber>
</Properties>
<ReportData Interval="1">
<Report Date="2015-03-24">
<Object Id="0" DeviceId="Device1" DeviceName="Device_1" ObjectType="0" Name="New Zone0">
<Count StartTime="09:26:27" EndTime="09:27:00" Enters="1" Exits="2" Status="0"/>
</Object>
</Report>
</ReportData>
</Metrics>





i想删除行





i want to remove line

POST / HTTP/1.1
Host: 192.168.0.21:2010
Content-Length: 725
Connection: Keep-Alive



(空格)



所以我的第一行开始于





请有人帮助我


(white space)

so my first line start from


please somebody help me

推荐答案

这不是XML。 XML从 prolog <?xml version =1.0?> 开始,第一行是HTTP请求行。请看我对这个问题的评论。



从字符串中删除一些行是一个微不足道的问题(有人真的需要帮助吗?:-)),但是这不是你想要做的。



请参阅: https://msdn.microsoft.com/en-us/library/system.web.httprequest%28v=vs.110%29.aspx



第一个例子显示了一个ASP.NET页面如何处理从请求某个页面的客户端发送到服务器端的HTTP请求;使用 Page 类的 Request 属性。您可以使用 Get * Stream 方法之一获取网络流并读取所有请求数据。在这种情况下,您可以在没有HTTP请求标头的情况下获取它,可以通过 System.Web.HttpRequest 属性访问它们。换句话说,已经为你完成了原始HTTP文本块的解析。



对不起,我不知道你是怎么得到你的文字的'显示。可能你做了别的事情。无论如何。感谢您解释在回复我的评论时如何获得原始HTTP请求,但我不知道为什么。最有可能的是,你需要如上所述。如果您想做其他事情,请解释。



另请参阅: http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol

你真的需要了解网络是如何工作的。



-SA
This is not XML. XML is starting from the prolog <?xml version="1.0"?>, and those first lines are the HTTP request lines. Please see my comment to the question.

Removing some lines from the string is the trivial issue (does anyone really need to help with that? :-)), but this is not what you probably want to do.

Please see: https://msdn.microsoft.com/en-us/library/system.web.httprequest%28v=vs.110%29.aspx.

The first example shows how an ASP.NET page can handle HTTP request sent to the server side from a client requesting some page; by using the Request property of the Page class. You can get a network stream using one of the Get*Stream methods and read all the request data. In this case, you get it without HTTP request headers, which can be accessed via those System.Web.HttpRequest properties. In other words, the parsing of raw HTTP text block is already done for you.

Sorry, I have no idea how did you obtain the text you've shown. Probably you did something else. No matter. Thank you for explaining how you got the raw HTTP request in your reply to my comment, but I have no idea why. Most likely, you need to so what I described above. If you wanted to do something else, please explain.

See also: http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol.
You really need to get an idea on how Web works.

—SA


这篇关于删除不需要的XML行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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