How To Add New Sub-hierarchy In XML

Apr 3, 2014

I have next xml stucture:
 
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<services>
    <people>
        <name>Julia</name>
        <secondName>Roberts</secondName>
    </people>
</services>

So, I need to add new <people>...</people> stucture. I made next solution:
 
NodeList employees = doc.getElementsByTagName("people");
        Element emp = null;
        for (int i = 0; i < employees.getLength(); i++) {
            emp = (Element) employees.item(i);
            Element people = doc.createElement("people");

[Code] ....

Then I got
 
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<services>
    <people>
        <name>Julia</name>
        <secondName>Roberts</secondName>
    </people>
    <name>Robert</name>
    <secondName>Deniro</secondName>
</services>
 
Yes, I got the new person in my xml file, but it without

<people>...</people>
 
Where I did mistake in my algorithm?

View Replies


ADVERTISEMENT

Constructors In Class Hierarchy?

Feb 9, 2014

I remember reading that a super() call to parent no-argument constructor is automatically inserted by compiler. So, if i have a chained hierarchy of classes (starting at top, with Object), will there be a chain of super() calls, going from bottom to top in the chain ? Will a super() call be inserted in child, if i provide a no-argument constructor for this class ?

View Replies View Related

Extending Classes In Inheritance Hierarchy

Jan 4, 2015

I have a working program, except that it does not calculate the credit hours and the financial aid. When I enter an input, it works, until it should show the student name, credit hours and financial aid. the error i get from the command is "Hours invalid for false student". Here is the program i think i might have the problem.

import java.text.DecimalFormat;
public abstract class Student
{
//initialise variables
String name;
int creditHrs;

[Code] .....

View Replies View Related

Naming Projects In Eclipse (hierarchy)

Jan 27, 2014

Below I've attached a screenshot of how I've been naming my various java projects as I go through my current textbook. I'm not sure if I'm naming them correctly. I'm on chapter 5 of Introduction to Java Programming by Y. Daniel Liang and he is currently discussing methods and classes. I'm not sure what my projects would be considered (methods, classes, or something arbitrary like projects). Further, if I wrote a program, like loanCalculator215 for example, how could i call that in a different program, like primeNumbers?

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved