JDOM Elements getChild with Namespace reference

Discussion in 'XML' started by gimme_this_gimme_that@yahoo.com, Apr 20, 2005.

  1. Guest

    I've loaded the following xml file into a JDOM Element :

    <?xml version="1.0" encoding="UTF-8"?>

    <epi:component build-version="Gold"
    component-id="sss0005style0001"
    component-type="Grids"
    description="A description."
    epi-build="105"
    epi-version="7.1"
    major-version="1"
    minor-version="0"
    title="Default Title"
    xmlns:epi="http://www.epicentric.com/deployment">

    <epi:required-component component-id="template0005"
    component-type="Style Types"
    major-version="7"
    minor-version="1"
    />

    <epi:detail>
    <style-info apply-template-header="true"
    description="A description."
    friendly-id="sss_grid.default"
    id="sss0005style0001"
    is-system="false"
    primary-filename="sss-grid-default.jsp"
    processing-type="JSP_BASED"
    template-default="false"
    template-uid="template0005"
    title="SPS Default Grid"
    visible="true"
    />
    </epi:detail>
    </epi:component>


    The statement :

    Element elm1 = rootElement.getChild("required-component",
    Namespace.getNamespace("", "epi"));

    returns null for elm1. Why? What am I doing wrong?
    , Apr 20, 2005
    #1
    1. Advertising

  2. Romin Guest

    Your Namespace record is not correct. As per your XML instance, you
    should create your JDOM Namespace object as follows:

    Namespace NS =
    Namespace.getNamespace("epi","http://www.epicentric.com/deployment");

    Then, you can use:
    Element elm1 = rootElement.getChild("required-component",NS);

    It should fine after that!

    Cheers,
    Romin.
    Romin, Apr 20, 2005
    #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. Wendy S
    Replies:
    1
    Views:
    6,355
    Darren Davison
    Aug 5, 2003
  2. Bernd Oninger
    Replies:
    4
    Views:
    12,268
    GIMME
    Jun 21, 2004
  3. Tinker
    Replies:
    4
    Views:
    5,298
    Harry Bosch
    Oct 9, 2005
  4. puzzlecracker

    JDOM withut namespace

    puzzlecracker, Feb 17, 2006, in forum: Java
    Replies:
    0
    Views:
    385
    puzzlecracker
    Feb 17, 2006
  5. Bernd Oninger
    Replies:
    3
    Views:
    2,874
    GIMME
    Jun 21, 2004
Loading...

Share This Page