JDOM Elements getChild with Namespace reference

  • Thread starter gimme_this_gimme_that
  • Start date
G

gimme_this_gimme_that

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?
 
R

Romin

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,999
Messages
2,570,246
Members
46,841
Latest member
WilmerBelg

Latest Threads

Top