Solved

Viewing contents of files that use XML tags

Posted on 2011-03-18
7
356 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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.
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

734 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