Software Development
Member Avatar

xml file

<?xml version="1.0" encoding="UTF-8" standalone="no"?><movies>
    <movie id="1111">
        <title>Blackhat</title>
        <genre>thriller</genre>
        <duration> 90 mins </duration>
    <age>28</age></movie>

    <movie id="1002">
        <title>The Wedding Ringer</title>
        <genre>comedy</genre>
        <duration> 100 mins </duration>
    </movie>
    <movie id="1003">
        <title>The Avengers</title> …
Topic by sing1006

It can be done, but you have the wrong approach. You must create the Element objects, and then create/set the Text in them. You will need to add the Element …

Software Development
Member Avatar
try {
    File file = new File("/Users/Alex Ting/Desktop/test2/MovieList.xml");

    DocumentBuilder dBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();

    Document doc = dBuilder.parse(file);

    NodeList movielist = doc.getElementsByTagName("movie");
    for(int i =0;i<movielist.getLength(); i++){
        Node m=movielist.item(i);
        if(m.getNodeType()==Node.ELEMENT_NODE){
        Element movie = …
Topic by sing1006

Here's one way:
System.out.println("title = " + movie.getElementsByTagName("title").item(0).getTextContent());

Software Development
Member Avatar

ok, so i know this is stupid and probably the easiest thing in java but my brain is not working right now. so i'll ask, how do you add the …

Topic by noobjavacoder

You already have most of the right stuff there. You are correct in thinking that you do not need a vector, array or list.

Think of how you would total …

Software Development
Member Avatar

Hi I'm new to this forum and to java, I have some work to do which requires that I have to write a program that reads in a list of …

Topic by Rachy3091

Farrukh:
We help people with the programs that they write themselves. Please make an attempt to solve the problem yourself. And if you are still having problems, please post a …

Software Development
Member Avatar

Hi there. Complete beginner on Java and OO principles. Having a little trouble in trying to figure out how to make objects move across the screen. Eventually, this will be …

Topic by larnacode
  1. I don't see any call to the move() method anywhere.
  2. You probably want to create the Earth outside the loop.
Software Development
Member Avatar

Hi to everybody...
Iam new to Webservices …..
Can anybody tell me two things …....

1)What is the difference between the soap and rest webservices..
2)Which one is more secure... …

Topic by kanakaraj.karre
  1. "difference between soap and restful web service" info
  2. SOAP contains security standards. Restful web services use HTTP security. They can both be secured.
Software Development
Member Avatar

why do most people use brackets in this way when it comes to Java. Pospular IDEs also use this method by default

class Test{

public void test(){

}

}

than …

Topic by silvercats

Agreed. Some prefer the first to have more visible lines within a single screen.

Code styles are like religion, they'll trigger holy wars.

Software Development
Member Avatar

Using 3 different for loops, write a java program to give the following output. The

program requires no user input. Save the program as ThreeLoops.java

Countdown...

10

9

8

7 …

Topic by school12345

You just copy/pasted your assignment without even a moment taken to explain what help you need. That's highly disrespectful to the many people who give their time to help others …

Software Development
Member Avatar

I'm new in java, so I'm not very good at it yet and my teacher has stumped me. We are supposed to make a bot for a game called snacktime, …

Topic by Benny_1

hey i'm in a similar situation as you where i'm trying to program a snacktime bot and i'm lost as to where I should start, would you mind posting your …

Software Development
Member Avatar

I'm new in java, so I'm not very good at it yet and my teacher has stumped me. We are supposed to make a bot for a game called snacktime, …

Topic by Benny_1

The class is now over and our bot turned out awesome! There was a giant snacktime tournament and our bot got to the finals! Sadly, for the finals match our …

Software Development
Member Avatar

I'm new in java, so I'm not very good at it yet and my teacher has stumped me. We are supposed to make a bot for a game called snacktime, …

Topic by Benny_1

Personally, I would make the bot smarter, rather than adding sound.

Software Development
Member Avatar

I'm new in java, so I'm not very good at it yet and my teacher has stumped me. We are supposed to make a bot for a game called snacktime, …

Topic by Benny_1

I plan on adding a soundtrack :D

Waste of time.

But it could be cool to growl like a tiger (or something like this) when going to take food …

Software Development
Member Avatar

I'm new in java, so I'm not very good at it yet and my teacher has stumped me. We are supposed to make a bot for a game called snacktime, …

Topic by Benny_1

Also, I did realize that this was very similar to robocode, and I used to play that game a lot until my classwork became an overload. When this class is …

Software Development
Member Avatar

I'm new in java, so I'm not very good at it yet and my teacher has stumped me. We are supposed to make a bot for a game called snacktime, …

Software Development
Member Avatar

I'm new in java, so I'm not very good at it yet and my teacher has stumped me. We are supposed to make a bot for a game called snacktime, …

Topic by Benny_1

I would very highly recommend using an iterative approach. (...with automated JUnit tests, if you can manage it. ;-)

Like...

Version 1: Always move to the closest snack.

Version 2: …

Software Development
Member Avatar

I'm new in java, so I'm not very good at it yet and my teacher has stumped me. We are supposed to make a bot for a game called snacktime, …

Topic by Benny_1

But I'm stuck on the methods for how far I should move.
... I have no idea how to calculate the angle (in radians (I hate radians)).
...

Software Development
Member Avatar

Hi recently while trying to solve a core Java algorithm question I got trapped into a problem.

Let me explain the puzzle.

There is a series of numbers. where …

Topic by thegreymatter

This is my solution:

    public static TreeSet<Integer> getPossibleLastValue(final int n, int a, int b) {
        final TreeSet<Integer> result = new TreeSet<>();
        if (n == 1) {
            result.add(0);
        } else if …
Software Development
Member Avatar

Hello below is my code for a program that reads in integers rom keyboard input and creates two polynomials from that input and then does some maths functions on them. …

Topic by Bradoz

Solved most of issues, going to recondense single issues alot easier to rea
d

Software Development
Member Avatar

Hello below is my code for a program that reads in integers rom keyboard input and creates two polynomials from that input and then does some maths functions on them. …

Topic by Bradoz

Cheers.
I have been working on this since i posted it and yes realise i prob shouldnt have posted the whole massive chunk at once.

problem i have now is …

Software Development
Member Avatar

Can anyone help me to write java program?
I'm using BlueJ for this assignment.

This assignment is to write a program to calculate loan repayments. Banks and/or finance companies loan …

Topic by Lee_8

Yes, people here will help - but do read the DaniWeb rules first, especially
"Do provide evidence of having done some work yourself if posting questions from school or work …

Software Development
Member Avatar

After trying different things for about a week i have come to the conclusion i am lost. Can someone please show me how to do this.

This assignment, based on …

Software Development
Member Avatar

Hey guys im completely new to programming and im complete stuck and any help to comlete my assingment would be greatly appreciated. heres my assingment.
Your task for this assignment …

Software Development
Member Avatar

Hi recently while trying to solve a core Java algorithm question I got trapped into a problem.

Let me explain the puzzle.

There is a series of numbers. where …

Software Development
Member Avatar

Hi recently while trying to solve a core Java algorithm question I got trapped into a problem.

Let me explain the puzzle.

There is a series of numbers. where …

Topic by thegreymatter

I made some GUnit tests for it:

import junit.framework.TestCase;
import java.util.TreeSet;

public class SolutionTest extends TestCase {

    public void testN0() {
        assertEquals(new TreeSet<Integer>() {}, Solution.getPossibleLastValue(0, 1, 2));
    }

    public void …
Software Development
Member Avatar

Hi, My name is Micky.

I have requirement, but i don't know how to start it, could anyone help me out. here is the requirement.

In a class there are …

Topic by salesforce

Start by defining a Student class that has instance variables for name. marks etc.
Input the raw data, create the instances of Student and add them to a List like …

Software Development
Member Avatar

I have just started looking into vim, and It seems very cool indeed ! However, I am not sure whether I should use it for everything or if I should …

Topic by pwolf

I would personally use something like Eclipse/IntelliJ because it "just works" out of the box and makes it easy to navigate complicated projects. Sure, you can use your Vim'fu to …

Software Development
Member Avatar

Hey guys im completely new to programming and im complete stuck and any help to comlete my assingment would be greatly appreciated. heres my assingment.
Your task for this assignment …

Topic by astrid.deliz

This is what i have so far.

Please don't think we are fools. We know where you copied that from, and so will your teacher after 15 seconds with …

Software Development
Member Avatar

Hi recently while trying to solve a core Java algorithm question I got trapped into a problem.

Let me explain the puzzle.

There is a series of numbers. where …

Topic by thegreymatter

There is something to be said for stepping back from the code and problem, and giving a really good "think" to the problem and how one could solve it.

I …

Software Development
Member Avatar

Could someone explain java recursion. I don't understand it.

Topic by ife_1

Recursion is when a function/method calls itself. This is common for binary search, fibbonacci routines, etc. It is very basic computer science and has nothing to do with Java per …

Software Development
Member Avatar

Hi, My name is Micky.

I have requirement, but i don't know how to start it, could anyone help me out. here is the requirement.

In a class there are …

Topic by salesforce

So you want to read that data into memory -- into something like a List or array. And then you want to sort it -- based on "Marks" and "Percentage" …