XML reader

Discussion in 'XML' started by q3537wh@gmail.com, Nov 10, 2006.

  1. Guest

    Is there a program out there that can take a quasi-XML file and make it
    user-friendly and easy to read? By quasi-XML I mean a plain text file
    that is in the format below.

    I know the time stamps messes up the format a bit. And these logs have
    hundreds, thousands of lines. You can see why I'm looking for something
    that can help me read them.

    TIA.

    15:52:46: [START] ===== Session Started 2006-09-19 15:52:46, UserRole
    = leader

    15:52:47: [COMMAND]
    <?xml version="1.0" encoding="UTF-8"?>
    <CommandList Id="1"><Command Id="1" TS="128031691673686869"><Action
    Type="Start"><Content Id="300016768"
    AuthToken="1,1268871847,1158695466,9218,003E67312BB747CD94EFF1A15982C4FB"/></Action></Command></CommandList>

    15:52:50: [RESPONSE]
    <Response><Command Id="1" Status="Success"/><Result ActionType="Start"
    CommandId="1" TS="128031691694557500"><Content CST="128031691676430000"
    Id="300016768" Status="Opened"><Group Audio="" Id="1" Name="Main Room"
    Owner="0" Type="Default"><Member Audio="" AudioNotified=""
    AudioConnection="" AudioConnectionType="" AudioId="-1" Name="Unknown"
    PhoneNum="" QA="" Speaking="" ConnQ="0" Emoticon="" Id="0"
    JT="128031691676430000" Name="5000038" Pid="" Role="Leader" S="1"
    Status="Added" Type="Data"/><Chat Id="2" Owner="0" S="0"
    Status="Started"/><Recorder Id="3" S="1"
    Status="Stopped"/><Presentation Id="17" S="1"
    Status="Stopped"/><Presentation Id="18" S="1" Status="Stopped"/><AppS
    Id="19" S="1" Status="Stopped"/><File Id="22" S="1"
    Status="Stopped"/></Group></Content></Result></Response>

    15:52:50: [COMMAND]
    <?xml version="1.0" encoding="UTF-8"?>
    <CommandList Id="1"><Command Id="2"
    TS="128031691709138553"><Destination ContentId="300016768"
    GroupId="1"><Member Id="0"/></Destination><Action
    Type="Get"/></Command></CommandList>

    15:52:50: [COMMAND]
    <?xml version="1.0" encoding="UTF-8"?>
    <CommandList Id="1"><Command Id="3"
    TS="128031691709338845"><Destination ContentId="300016768"/><Action
    Type="Get" Scope="Children"><Filter><Condition
    Type="Group"/></Filter></Action></Command></CommandList>

    15:52:51: [COMMAND]
    <?xml version="1.0" encoding="UTF-8"?>
    <CommandList Id="1"><Command Id="4"
    TS="128031691709438991"><Destination ContentId="300016768"
    GroupId="1"/><Action Type="Get" Scope="Children"><Filter><Condition
    Type="Presentation1"/></Filter></Action></Command></CommandList>

    15:52:51: [COMMAND]
    <?xml version="1.0" encoding="UTF-8"?>
    <CommandList Id="1"><Command Id="5"
    TS="128031691709438991"><Destination ContentId="300016768"
    GroupId="1"/><Action Type="Get" Scope="Children"><Filter><Condition
    Type="Presentation2"/></Filter></Action></Command></CommandList>

    15:52:51: [COMMAND]
    <?xml version="1.0" encoding="UTF-8"?>
    <CommandList Id="1"><Command Id="6"
    TS="128031691709438991"><Destination ContentId="300016768"
    GroupId="1"/><Action Type="Get" Scope="Children"><Filter><Condition
    Type="Presentation3"/></Filter></Action></Command></CommandList>

    15:52:51: [COMMAND]
    <?xml version="1.0" encoding="UTF-8"?>
    <CommandList Id="1"><Command Id="7"
    TS="128031691709539137"><Destination ContentId="300016768"
    GroupId="1"/><Action Type="Get" Scope="Children"><Filter><Condition
    Type="Presentation4"/></Filter></Action></Command></CommandList>

    15:52:51: [COMMAND]
    <?xml version="1.0" encoding="UTF-8"?>
    <CommandList Id="1"><Command Id="8"
    TS="128031691709539137"><Destination ContentId="300016768"
    GroupId="1"/><Action Type="Get" Scope="Children"><Filter><Condition
    Type="Presentation5"/></Filter></Action></Command></CommandList>

    15:52:51: [COMMAND]
    <?xml version="1.0" encoding="UTF-8"?>
    <CommandList Id="1"><Command Id="9"
    TS="128031691709539137"><Destination ContentId="300016768"
    GroupId="1"/><Action Type="Get" Scope="Children"><Filter><Condition
    Type="Presentation6"/></Filter></Action></Command></CommandList>

    15:52:51: [COMMAND]
    <?xml version="1.0" encoding="UTF-8"?>
    <CommandList Id="1"><Command Id="11"
    TS="128031691709639283"><Destination ContentId="300016768"
    GroupId="1"/><Action Type="Start"
    Notify="Group"><Presentation7/></Action></Command></CommandList>

    15:52:51: [COMMAND]
    <?xml version="1.0" encoding="UTF-8"?>
    <CommandList Id="1"><Command Id="12"
    TS="128031691709639283"><Destination ContentId="300016768"
    GroupId="1"/><Action Type="Start"
    Notify="Group"><Note/></Action></Command></CommandList>

    15:52:52: [COMMAND]
    <?xml version="1.0" encoding="UTF-8"?>
    <CommandList Id="1"><Command Id="13"
    TS="128031691709639283"><Destination ContentId="300016768"/><Action
    Type="Get" Scope="Children"><Filter><Condition
    Type="Audio"/></Filter></Action></Command></CommandList>

    15:52:52: [COMMAND]
    <?xml version="1.0" encoding="UTF-8"?>
    <CommandList Id="1"><Command Id="14"
    TS="128031691709939721"><Destination ContentId="300016768"/><Action
    Type="Get"><Property Name="Door"/></Action></Command></CommandList>
     
    , Nov 10, 2006
    #1
    1. Advertising

  2. wrote:

    > Is there a program out there that can take a quasi-XML file and make it
    > user-friendly and easy to read? By quasi-XML I mean a plain text file
    > that is in the format below.


    Use an AWK script. The following script works, I tested it.

    BEGIN {
    n=1
    filename = "quasi_xml_dat_" n ".xml"
    }

    {
    if (/^[0-9]*:/) {
    if (n>0)
    close(filename)
    filename = "quasi_xml_dat_" ++n ".xml"
    } else {
    print $0 >> filename
    }
    }

    The result you get is something like this:

    > ls -l *xml

    -rw-r--r-- 1 kahrs users 268 2006-11-11 19:52 quasi_xml_dat_10.xml
    -rw-r--r-- 1 kahrs users 268 2006-11-11 19:52 quasi_xml_dat_11.xml
    -rw-r--r-- 1 kahrs users 268 2006-11-11 19:52 quasi_xml_dat_12.xml
    -rw-r--r-- 1 kahrs users 235 2006-11-11 19:52 quasi_xml_dat_13.xml
    -rw-r--r-- 1 kahrs users 226 2006-11-11 19:52 quasi_xml_dat_14.xml
    -rw-r--r-- 1 kahrs users 249 2006-11-11 19:52 quasi_xml_dat_15.xml
    -rw-r--r-- 1 kahrs users 213 2006-11-11 19:52 quasi_xml_dat_16.xml
    -rw-r--r-- 1 kahrs users 1 2006-11-11 19:52 quasi_xml_dat_2.xml
    -rw-r--r-- 1 kahrs users 254 2006-11-11 19:52 quasi_xml_dat_3.xml
    -rw-r--r-- 1 kahrs users 792 2006-11-11 19:52 quasi_xml_dat_4.xml
    -rw-r--r-- 1 kahrs users 222 2006-11-11 19:52 quasi_xml_dat_5.xml
    -rw-r--r-- 1 kahrs users 248 2006-11-11 19:52 quasi_xml_dat_6.xml
    -rw-r--r-- 1 kahrs users 268 2006-11-11 19:52 quasi_xml_dat_7.xml
    -rw-r--r-- 1 kahrs users 268 2006-11-11 19:52 quasi_xml_dat_8.xml
    -rw-r--r-- 1 kahrs users 268 2006-11-11 19:52 quasi_xml_dat_9.xml

    > cat quasi_xml_dat_10.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <CommandList Id="1"><Command Id="7"
    TS="128031691709539137"><Destination ContentId="300016768"
    GroupId="1"/><Action Type="Get" Scope="Children"><Filter><Condition
    Type="Presentation4"/></Filter></Action></Command></CommandList>

    > I know the time stamps messes up the format a bit. And these logs have
    > hundreds, thousands of lines. You can see why I'm looking for something
    > that can help me read them.


    Yes, the time stamps mess up the format.
    The script will work for millions of lines.
    Notice that the script is only about 80% of a
    complete solution because some of your quasi-XML
    section have no XML declaration header.
     
    =?ISO-8859-1?Q?J=FCrgen_Kahrs?=, Nov 11, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. martin
    Replies:
    0
    Views:
    361
    martin
    Jul 29, 2003
  2. Aaron

    XML reader error

    Aaron, Aug 24, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    2,779
    MS News \(MS ILM\)
    Aug 24, 2003
  3. www.guanfenglin.com

    XML config file reader

    www.guanfenglin.com, Dec 18, 2005, in forum: Java
    Replies:
    1
    Views:
    3,405
    =?ISO-8859-2?Q?Tomasz_Ko=B6mider?=
    Dec 18, 2005
  4. Guilherme Grillo

    reader inside a reader

    Guilherme Grillo, Nov 7, 2007, in forum: ASP .Net
    Replies:
    5
    Views:
    534
    sloan
    Nov 7, 2007
  5. Pokkai Dokkai
    Replies:
    1
    Views:
    241
    Hassan Schroeder
    Mar 24, 2008
Loading...

Share This Page