Solved

Viewing contents of files that use XML tags

Posted on 2011-03-18
7
351 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Mobile menu navigation , its html and css 6 54
Bootstrap 3 website error 14 45
Angular 2 - Issue in page Layout 2 47
How to avoid jquery conflicts in Wordpress ? 4 24
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
Find out what you should include to make the best professional email signature for your organization.
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

910 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

23 Experts available now in Live!

Get 1:1 Help Now