Solved

Viewing contents of files that use XML tags

Posted on 2011-03-18
7
348 Views
Last Modified: 2012-05-11
Howdy,

I am working with IBM WebSphere creating profiles on an AIX server.  That statement is only important in that it defines the processes used to create some XML files.

I really need a program that will read and display the relevant contents of these XML files.  Using the XML tags, several "records" are created that have <record></record> brackets with a number of things listed for each record.  See the example in the code section below:


I could write some code using VB, Shell Script or Sed or awk that could parse and display all of this for me, but It is beyond the scope of my job and I would probably be in trouble for taking company time to accomplish this.

So, with that said, I would like the program/script to display each record something like this (using the examples in the code section below):

Sequence  Level   Date              Millis                   Method                          Thread Class   Logger
36              INFO    03-18-2011  1300470373974 unmarshallPrerequisite  0          com.ibm.wsspi.profile   ibm.wsspi.profile......

Message
Testing ../dmgr as an absolute or relative path.


Actually I would be happy to be able to pick and choose and have it list only the Sequence and the Message:

Sequence    Message
36                Testing ../dmgr as an absolute or relative path.

Or if you already have a shell script, sed or awk script, grep script, etc already written, I would really appreciate anything you could offer.

Thanks for your time.

Fred
<record>
    <date>2011-03-18T10:46:13</date>
    <millis>1300470373974</millis>
    <sequence>36</sequence>
    <logger>com.ibm.wsspi.profile.WSProfileTemplate</logger>
    <level>INFO</level>
    <class>com.ibm.wsspi.profile.WSProfileTemplate</class>
    <method>unmarshallPrerequisite</method>
    <thread>0</thread>
    <message>Testing ../dmgr as an absolute or relative path.</message>
</record>
<record>
    <date>2011-03-18T10:46:13</date>
    <millis>1300470373982</millis>
    <sequence>37</sequence>
    <logger>com.ibm.wsspi.profile.WSProfileTemplate</logger>
    <level>INFO</level>
    <class>com.ibm.wsspi.profile.WSProfileTemplate</class>
    <method>unmarshallPrerequisite</method>
    <thread>0</thread>
    <message>../dmgr is a valid relative profile template path.</message>
</record>

Open in new window

0
Comment
Question by:Fhnorth
  • 4
  • 3
7 Comments
 
LVL 2

Accepted Solution

by:
choukssa earned 500 total points
ID: 35169678
Try this.... This is with least effort.

I added <root> element to your xml.

<root>
<record>
    <date>2011-03-18T10:46:13</date>
    <millis>1300470373974</millis>
    <sequence>36</sequence>
    <logger>com.ibm.wsspi.profile.WSProfileTemplate</logger>
    <level>INFO</level>
    <class>com.ibm.wsspi.profile.WSProfileTemplate</class>
    <method>unmarshallPrerequisite</method>
    <thread>0</thread>
    <message>Testing ../dmgr as an absolute or relative path.</message>
</record>
<record>
    <date>2011-03-18T10:46:13</date>
    <millis>1300470373982</millis>
    <sequence>37</sequence>
    <logger>com.ibm.wsspi.profile.WSProfileTemplate</logger>
    <level>INFO</level>
    <class>com.ibm.wsspi.profile.WSProfileTemplate</class>
    <method>unmarshallPrerequisite</method>
    <thread>0</thread>
    <message>../dmgr is a valid relative profile template path.</message>
</record>
</root>

Open in new window


Now open this in excel.
Excel will ask to display xml as table .. .choose yes.
now you have a table with each <record> tag as one row

--choukssa
0
 

Author Comment

by:Fhnorth
ID: 35181568
I tried this a number of ways.  First I just pasted it into Excel.  Then I saved it as a wordpad file (.rtf) and tried to import it... failed.  I saved it as an .xml file adn tried to import it.  It gave me three options:
(in the screencast page below.)

I tried each one and got a similar error.

What am I missing?
Fhnorth-434998.flv
0
 
LVL 2

Expert Comment

by:choukssa
ID: 35185724
Select Option 1 - Select as XML list

After this, you will get another popup

"The specified XML source does not refer to a schema. Excel will create a schema based on the XML Source Data"

Click OK

And we are done.

--choukssa  
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:Fhnorth
ID: 35185752
I wish it were that simple.  I did select option 1 and this is the error I got:

I am using Office 2003... does that make the difference?
Fhnorth-435201.flv
0
 
LVL 2

Expert Comment

by:choukssa
ID: 35186269


I have tried it with both Excel 2003 / 2007.

--choukssa
0
 

Author Comment

by:Fhnorth
ID: 35190628
choukssa:

Let me review the steps:
1. I copied exactly what is in the code box on your post with the <root></root> entries that you added
2. Opened a document with WordPad, pasted it and renamed the document to test.xml
3. Opened Excel 2003 and browsed for and opened test.xml
4. I got the dialog box with the three options (see my post with ID: 35181568)
5. I got the error (see my post with ID: 35185752)

What did I do wrong?
0
 

Author Comment

by:Fhnorth
ID: 35191883
My apologies... I tried it on the real file, not the mock up that we were passing back and forth in our posts here, and it worked great.

Thanks.  It is exactly what I needed!  
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now