Total members 10261 | Gratitudes |It is currently Wed May 23, 2012 10:01 am Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 6 posts ] 
Author Question
 Question subject: update an xml file with jaxb and accessing to its elements
PostPosted: Wed Jul 15, 2009 10:47 am 
Offline
Newbie
User avatar

Joined: Wed Jul 15, 2009 8:39 am
Posts: 21
Has thanked: 0 time
Have thanks: 0 time

HI

I am working with jaxb .I has get my java classes from my schema xml .
My root element is binded to a java classs with getters and setters for its attributes and a method that returns a list of the other elements .
Code:
public List<Object> getContent() {
        if (content == null) {
            content = new ArrayList<Object>();
        }
        return this.content;
    }


I have an xml file that contains just the basic elements and i want to insert elemets and values of attributes .I succed to add attributes to my root element but how can i acceed by this method to other elements and use its methods? IDE:   Netbeans 6.5.1 Technology:  jaxb


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: update an xml file with jaxb and accessing to its elements
PostPosted: Thu Jul 16, 2009 6:00 am 
Offline
Mastermind
User avatar

Joined: Tue Mar 27, 2007 10:55 pm
Posts: 2279
Location: Earth
Has thanked: 39 time
Have thanks: 61 time
jaxb/unmarshall-from-xml-using-jaxb-t5294.html
jaxb/marshal-java-object-to-xml-file-t5293.html

_________________
Currenlty programming with : java , html , php , and javascript . (OCJP-6 certified )


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: update an xml file with jaxb and accessing to its elements
PostPosted: Thu Jul 16, 2009 8:37 am 
Offline
Newbie
User avatar

Joined: Wed Jul 15, 2009 8:39 am
Posts: 21
Has thanked: 0 time
Have thanks: 0 time
My problem that that the method getContent return different objects which are nodes .
I can just access to the root by :
Code:
root =(root)u.unmarshal(new FileInputStream("A.xml")

i want to access to the methods of the binded nodes .


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: update an xml file with jaxb and accessing to its elements
PostPosted: Thu Jul 16, 2009 9:51 am 
Offline
Newbie
User avatar

Joined: Wed Jul 15, 2009 8:39 am
Posts: 21
Has thanked: 0 time
Have thanks: 0 time
When i access to the first node(E) just after the root and i want to display the name of the it first subnode with this code


Code:
System.out.println(E.getContent();.get(0).getClass().getName());


I get in output this:

javax.xml.bind.JAXBElement


Please i need an urgent help


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: update an xml file with jaxb and accessing to its elements
PostPosted: Sun Jul 19, 2009 8:31 am 
Offline
Mastermind
User avatar

Joined: Tue Mar 27, 2007 10:55 pm
Posts: 2279
Location: Earth
Has thanked: 39 time
Have thanks: 61 time
am just wondering . we don't you try to do the following :

Code:
System.out.println(E.getContent().get(0).getClass().getName());


did u tried to do the following
Code:
System.out.println(E.getContent().getClass().getName());

_________________
Currenlty programming with : java , html , php , and javascript . (OCJP-6 certified )


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: update an xml file with jaxb and accessing to its elements
PostPosted: Tue Jul 21, 2009 7:01 am 
Offline
Newbie
User avatar

Joined: Wed Jul 15, 2009 8:39 am
Posts: 21
Has thanked: 0 time
Have thanks: 0 time
i HAVE RESOLVED tHE PROBLEM :

List Li=E.getContent();
JAXBElement D=(JAXBElement)Li.get(0);//it returns jaxb
NOEUD Da=( NOEUD)D.getValue();

thanks a lot


TOP
 Profile Send private message  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 6 posts ] 
Quick reply


  

 Similar topics
 Image Insert in Excel File Using POI
 ASP file structure
 Search records from text file
 error closing file matlab save
 How to download any file in jsp.
 Add border around ordered list elements
 read php file in asp and display it as html
 javascript read file
 lesson6: XSD Complex Empty Elements
 How to make PHP form data saved into txt file

All times are UTC [ DST ]


Users browsing similar posts

Users browsing this forum: No registered users and 4 guests



Jump to:  
Previous Question | Next Question 




Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team