Total members 11895 |It is currently Tue Dec 03, 2024 5:36 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





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




Author:
Newbie
User avatar Posts: 19
Have thanks: 0 time

jaxb/unmarshall-from-xml-using-jaxb-t5294.html
jaxb/marshal-java-object-to-xml-file-t5293.html

_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 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 .


Author:
Newbie
User avatar Posts: 19
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


Author:
Newbie
User avatar Posts: 19
Have thanks: 0 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());


_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 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


Author:
Newbie
User avatar Posts: 19
Have thanks: 0 time
Post new topic Reply to topic  [ 6 posts ] 

  Related Posts  to : update an xml file with jaxb and accessing to its elements
 update an xml file with jaxb     -  
 Load file and update content using AJAX and JQuery     -  
 php Accessing a Property from Within a Method     -  
 Dynamically Setting and Accessing Variables     -  
 Accessing files in remote server (unix/windows) using JSP     -  
 XML using JAXB API in java     -  
 Unmarshall From XML using JAXB     -  
 how to use enum in jaxb unmarshalling     -  
 insert a namespace in a tag with jaxb     -  
 update query example     -  



Topic Tags

Java JAXB, Java XML
cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com