xmlbeans.jar newbie question

Discussion in 'XML' started by mlynch147, Jul 17, 2007.

  1. mlynch147

    mlynch147 Guest

    Hi

    Im trying to write some code that takes an xml string as an input
    parameter and from this string create an XML Object, and then using
    the attributes of this object, use them to populate one of my
    classes... I though it would work something like this....


    public static void stringToXML(String xmlString) {

    XmlObject xmlObj = XmlObject.Factory.newInstance();

    try {
    System.out.println("trying to parse xmlObj");
    xmlObj = XmlObject.Factory.parse(xmlString);

    myClass.setColour(xmlObj.getAttribute("Colour"));
    myClass.setSpeed(xmlObj.getAttribute("Speed"));
    etc...

    But this doesnt seem to work.... can someone offer a bit of help to a
    newbie please?

    thanks
    marty
     
    mlynch147, Jul 17, 2007
    #1
    1. Advertising

  2. I don't know what "XmlObject" is. The usual object-based representation
    of XML is the W3C's Document Object Model (DOM).

    However, assuming that XmlObject is at least vaguely similar to the
    DOM... to get the attributes of a given element, you have to ask that
    specific element's object. I don't see any indication in your sketch
    that you're actually navigating the document tree to the proper point to
    retrieve that; it looks as if you're asking the root note, which has no
    attributes.

    You may want to look at a DOM tutorial. Many exist on the web, but my
    standard recommendation is to start with the resources at
    http://www.ibm.com/xml.


    --
    () ASCII Ribbon Campaign | Joe Kesselman
    /\ Stamp out HTML e-mail! | System architexture and kinetic poetry
     
    Joe Kesselman, Jul 17, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Arnold Peters
    Replies:
    0
    Views:
    630
    Arnold Peters
    Jan 5, 2005
  2. muttley
    Replies:
    0
    Views:
    2,786
    muttley
    Oct 20, 2005
  3. cyberco
    Replies:
    4
    Views:
    3,862
    Roedy Green
    Feb 14, 2006
  4. Replies:
    0
    Views:
    342
  5. mlynch147

    xmlbeans.jar newbie question

    mlynch147, Jul 17, 2007, in forum: XML
    Replies:
    0
    Views:
    350
    mlynch147
    Jul 17, 2007
Loading...

Share This Page