Solved

Java & XML: XML decoding and Java Programming

Posted on 2004-10-10
10
171 Views
Last Modified: 2010-03-31
I've got an xml file with the following syntax:
<?xml version="1.0" encoding="iso-8859-1"?>
<data>
      <topic1>
            <topicname>TOPIC1</topicname>
            <link1>
                  <url>http://www.something.net/</url>
                  <urltext>something</urltext>
                  <description>something somewhat somewhere</description>
                  <imageurl>images/something.jpg</imageurl>
            </link1>
      </topic1>
      <topic2>
            <topicname>TOPIC2</topicname>
            <link1>
                  <url>http://www.somewhat.net/</url>
                  <urltext>somewhat</urltext>
                  <description>somewhat somewhere</description>
                  <imageurl>images/somewhat.jpg</imageurl>
            </link1>
      </topic2>
      <topic3>
            <topicname>TOPIC3</topicname>
            <link1>
                  <url>http://www.somewhere.net/</url>
                  <urltext>somewhere</urltext>            
                  <description>somewhere</description>
                  <imageurl>images/somewhere.jpg</imageurl>
            </link1>
      </topic3>
</data>

I need a Java applet to use on my website (sized 472px * 282px)
Which is supposed to read the xml file and put the links and all it's info onto site.

I've been thinking the applet should have 2 col. one on each side of applet (EAST and WEST)
- The left one should have the <topics> with their <urltext> and should be able to goto the <url> when clicked.
- The right one should update on mouseover the links on the left. It's design would have an image (sized 100px * 73px) on top, followed by "URL: <url>", "Text: <urltext>" and "Description: <description>"

I'm not expecting a complete solution from EE members, but I hope for a little help to get me going.

Thanks in advance.
eX.



0
Comment
Question by:Gaute Rønningen
  • 6
  • 4
10 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 12271882
>>The right one should update on mouseover the links on the left.

Could you explain this a bit more?
0
 

Author Comment

by:Gaute Rønningen
ID: 12271988
The right column (JTextArea or something) should dynamically update as one moves the mouse over a link on the left one.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12272026
>>should dynamically update

In what way and why?
0
 

Author Comment

by:Gaute Rønningen
ID: 12272053
When you move the mouse over a link, the fields on the right should update, using the data from the xml file. To show a description of the link and a preview of the site through an image.

Why? Because I've seen it done on other sites, and want it on mine... (I don't know if they used xml, but still) Sadly I cannot remember which sites...

I'm not sure what you meant by that question, but I tried to answer at the best of my knowledge.

I'll post a simple image of how I want it if you'd like?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12272071
>>I'll post a simple image of how I want it if you'd like?

No - it's OK - i've got the picture now - i'll have a think
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 86

Expert Comment

by:CEHJ
ID: 12272094
This is what i'd do:

a. Use a JEditorPane for the left pane
b0. Parse the xml document in a DOM way
b1. Make a Map of descriptions using the links as keys and the descriptions as values
b3. Use the Java transform package to transform the xml into html
c. Add the html as a String to the left pane
d. Add HyperlinkListeners to the links
e. Change the content of the right pane when the HyperlinkListener fires
0
 

Author Comment

by:Gaute Rønningen
ID: 12272142
I feel bad for asking you this, because you probably have more important things to do.
But on the other hand I'm kinda new to Java... Meaning I know some simple things about GUI and JDBC and that's it.

a. I've never used JEditorPane, but I guess the API explains it.
b0. The only thing I've used DOM in before was in VBA. So I could use some kind of tutorial.
b1. Need tutorial.
b3. In the back of my head somewhere.
c. Same as above.
d. Need tutorial.
e. Need tutorial.
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 500 total points
ID: 12272173
I can point you in the right direction. I would take it bit by bit. Get stand alone parts working that you can later integrate into the complete solution. Start here:

http://javaalmanac.com/egs/

Look at the links right at the end of the page, then you can start looking at JEditorPane in the javax.swing section
0
 

Author Comment

by:Gaute Rønningen
ID: 12276346
I'm sorry, but I've decided to put this project on ice, and focus on school instead.

Anyways I thank you for helping and award you all the points.

(As for my website, I went for a standard Flash menu template, based on XML...)
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12284927
8-)
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

746 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

16 Experts available now in Live!

Get 1:1 Help Now