Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Viewing contents of files that use XML tags

Posted on 2011-03-18
7
Medium Priority
?
360 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 2000 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
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!

 

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

Technology Partners: 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

When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Suggested Courses
Course of the Month20 days, 16 hours left to enroll

810 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