如何使用特定字段名称将文本文件解析为xml格式?

时间:2014-07-02 14:56:52

标签: xml database parsing xml-parsing

我有一个ascii格式的文本文件。但我想将文件中的数据转换为xml格式。我的数据基本上是http get请求。我在下面放了一个数据样本。如果有人知道如何解析这种数据,请分享解决方案或至少是一个良好的开端。最终我的目标是将这些数据转储到mysql数据库中。我没有任何语言或平台偏好。所以,无论做什么,我都会去做。非常感谢您的回复。

131.162.134.169: HTTP/1.1 200 OK
Content-Type: text/html
Accept-Ranges: bytes
ETag: "1675772700"
Last-Modified: Fri, 30 Sep 2011 07:41:01 GMT
Content-Length: 10198
Date: Sat, 24 May 2014 23:19:06 GMT
Server: lighttpd/1.4.25-devel-fb150ff

<!doctype html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE"> 
<META HTTP-EQUIV="Expires" CONTENT="-1">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">   
<link rel="stylesheet" type="text/css" href="/web/css/style.css?v20">
<script language="javascript" src="/web/jquery/js/jquery_1.6.1.js"></script>
<script type="text/javascript" src="/web/jquery/jquery.cookie/jquery.cookie.js"></script>
<script type="text/javascript" src="/web/jquery/jquery.cookie/jquery.cookie.pack.js"></script>
<script type="text/javascript" src="/web/function/rc4.js"></script>
<link rel="STYLESHEET" type="text/css" href="/web/css/button_style.css">
<style>

body, html {margin:0; padding:0; border:0;
background-repeat:
131.162.207.119: HTTP/1.0 404 Not Found


131.162.200.38: HTTP/1.1 200 OK
Date: Sat, 24 May 2014 23:19:06 GMT
Server: Apache/2.2.6 (Unix)
Last-Modified: Mon, 08 Feb 2010 13:40:38 GMT
ETag: "57ef4-f8-f24d4180"
Accept-Ranges: bytes
Content-Length: 248
Content-Type: text/html

<HTML> 
 <HEAD> 
  <TITLE>E.C. Smith Herbarium</TITLE>
         <META HTTP-EQUIV="Refresh" CONTENT="1;
          URL=http://herbarium.acadiau.ca"> 
 </HEAD> 
 <BODY>
  <P><B><FONT FACE="Arial">E.C. Smith Herbarium</FONT></B></P> 
 </BODY>
</HTML>

文件中有数百行这样的行。但它有一个特定的模式,如One IP,然后是他们的响应数据。总的html正文部分将位于一个xml字段上。

0 个答案:

没有答案