« Previous Next »

Thread: XML Input Format Parameters

Last post 11-03-2006 12:25 PM by LogParser User : VBProEd. 8 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (9 items)

Sort Posts:

  • 11-01-2006, 3:49 PM

    XML Input Format Parameters

    I am using the Visual LogParser tool and am confused how to parse the following XML file looking for a specific USR_ID value of "MyUserIDHere".  As I understand it, Visual LogParser uses the Microsoft Log Parser tools for executing queries.  Any suggestions?  

    -Ed 

    <AUDIT_TRAIL>
    <TRANSACTION>
    <HDR>
    <ONLINE_PROG_ID v="XX0810N"></ONLINE_PROG_ID>
    <FETCH_DTM v="2003-02-24 09:12:21"></FETCH_DTM>
    <TRANS_STATUS v="SUCCESS"></TRANS_STATUS>
    <HDR_ACTION_CD v="S"></HDR_ACTION_CD>
    <USR_ID v="MyUserIDHere"></USR_ID>
    <WK_STATION_ID v="00065BAF2D11"></WK_STATION_ID>
    <TRANS_ID v="XX0503F"></TRANS_ID>
    <REVIEW_STATUS v=" "></REVIEW_STATUS>
    <KEYNAME v="51"></KEYNAME>
    <KEYVALUE v="MyUserIDHere"></KEYVALUE>
    <MODIFIED_DATA>
    <T04328 v=""></T04328>
    <T03054 v=""></T03054>
    <T04188 v="wztpjp"></T04188>
    </MODIFIED_DATA>
    </HDR>
    </TRANSACTION>  

  • 11-01-2006, 5:38 PM In reply to

    RE: XML Input Format Parameters

    Log Parser isn't very well suited for this format of XML. You might be able to get something of use by changing the fMode parameter. Try each of the three settings (Branch, Tree, or Node) and see if any of them will work for you.
  • 11-02-2006, 12:02 PM In reply to

    RE: XML Input Format Parameters

    Visual Log Parser XML queries:  Here is what I discovered.  Once I set the following values in the "XML Parameters" window and modified my query accordingly, I managed to extract 13 rows for a given userid in an XML log file with XML tags that use " v=" in data nodes.  I believe I read somewhere that space characters are converted to "@" so this character is required in the actual query. 

    dtNodes: -1

    fmode: Auto

    fnames; XPath

    iTsformat: (use default)

    rootXPath: /AUDIT_TRAIL/TRANSACTION/HDR

    Select /HDR/USR_ID/@v from c:\Audit_Log\AUDIT_02242003_07.xml where /HDR/USR_ID/@v = 'MyUserIDHere'

    (13 rows affected)

    Query time : 00:00:00.7777348

    Display time : 54ms

    This is my first attempt at using XML queries in Log Parser but I believe I managed to tame the beast.  Now you all know more the I do about XML file queries...LOL!

    Ed

  • 11-02-2006, 12:43 PM In reply to

    RE: XML Input Format Parameters

    Well, the above query works but after modifying the query to include other nodes (no syntax errors), no data values ever appear in the output area.  Hmmmm.
  • 11-02-2006, 12:44 PM In reply to

    RE: XML Input Format Parameters

    I'm very happy to hear you were able to figure out a query that gives you the data you need.
    Just so you know, the @ symbol is actually an indicator that the word after it (v in this case) is an attribute rather than an element. e.g.

    USERID is an element name, v is an attribute name so /USERID/@v selects the value of the v attribute.
  • 11-02-2006, 12:53 PM In reply to

    RE: XML Input Format Parameters

    LogParser User : VBProEd:
    Quote: I'm very happy to hear you were able to figure out a query that gives you the data you need. Just so you know, the @ symbol is actually an indicator that the word after it (v in this case) is an attri...

    Maybe I responded too quickly.  When I selected the USR_ID in the query and used it in the WHERE clause, it would show up in the results window.  However, as soon as I entered additional select values, no data would appear in the results window.  Where did I go wrong?

    Ed

  • 11-02-2006, 7:26 PM In reply to

    RE: XML Input Format Parameters

    can't tell you without the query you used and maybe some longer sample data.
  • 11-03-2006, 10:07 AM In reply to

    RE: XML Input Format Parameters

    Select /HDR/USR_ID/@v AS UserID, /HDR/WK_STATION_ID/@v AS WorkStationID, /HDR/TRANS_ID/@v AS TransID, /HDR/FETCH_DTM/@v AS DateTime from c:\Audit_Log\AUDIT_02242003_07.xml where /HDR/ONLINE_PROG_ID/@v = 'AU0001N'

    (12 rows affected)

    Query time : 00:00:01.4110379

    Display time : 99ms

    I have also attached my sample XML file to this post.  This query can find 12 rows yet no data ever appears in the window matching the where clause.

  • 11-03-2006, 12:25 PM In reply to

    RE: XML Input Format Parameters

    :/ Now that I see more of what you are trying to do, I have to go back to my original statement that LP isn't well designed for this type of XML input.
    However, you can easily use a straight XSL solution to get the output you are looking for.
    Here is an example XSL that you can invoke using msxsl:
    msxsl AUDIT_02242003_07.xml audit_xml_to_csv.xsl prog_id='AU0001N' -o output.csv
Page 1 of 1 (9 items)
Microsoft Communities