Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > JDOM Elements getChild with Namespace reference

Reply
Thread Tools

JDOM Elements getChild with Namespace reference

 
 
gimme_this_gimme_that@yahoo.com
Guest
Posts: n/a
 
      04-20-2005
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?

 
Reply With Quote
 
 
 
 
Romin
Guest
Posts: n/a
 
      04-20-2005
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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
JDOM withut namespace puzzlecracker Java 0 02-17-2006 03:14 AM
java.lang.NoSuchMethodError: org.jdom.Element: method getParent()Lorg/jdom/Element Tinker Java 4 10-09-2005 03:12 PM
JDOM: java.lang.NoClassDefFoundError: org/jdom/Content Bernd Oninger Java 4 06-21-2004 09:08 PM
JDOM: java.lang.NoClassDefFoundError: org/jdom/Content Bernd Oninger XML 3 06-21-2004 09:08 PM
Help with JDOM, turn org.jdom.Document -> org.w3c.dom.Document? Wendy S Java 1 08-04-2003 11:48 PM



Advertisments