473,387 Members | 1,536 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

JDOM Elements getChild with Namespace reference

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?

Jul 20 '05 #1
1 2334
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.

Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: mali_djuro | last post by:
Hi all, i used JDOM to create XML file. first, i get data from database and create Document object. in some data i have quotas, so it makes replacment in content of elements. for example: if i...
2
by: john smith | last post by:
hello, I am having to read an XML document and grab some elements and attributes and then convert that to anther XML document. Which should I use? JAX, DOM, JDOM? I don't really understand...
0
by: kyancy | last post by:
Hello All. We have several XML schemas to describe common component document parts. We then create new XML schemas as necessary that use "xsd:import schemaLocation=whateverLocation.." to include...
0
by: gimme_this_gimme_that | last post by:
Why is it that this works : root.getChild("detail",NS).getChild("site-export").getChild("category-list").addContent((Content)c); But this does not : Element detail =...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.