This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Other JSE/JEE APIs and the fly likes XML dealing with the NamedNodeMap interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "XML dealing with the NamedNodeMap interface" Watch "XML dealing with the NamedNodeMap interface" New topic
Author

XML dealing with the NamedNodeMap interface

jeff culler
Greenhorn

Joined: Dec 10, 2002
Posts: 10
NodeList theNodeList = parentNode.getChildNodes();
first_EditionSections.setNamedItem( theNodeList.item(1) );
here' a bit of the code.
keep getting java.lang.NullPointerException
Does the node I place in a NamedNodeMap must have
an attribute named "nodeName" or nodeName refer
to the actual name of the node?
I am sure all nodes point to actual xml.
Could someone perhaps post a sample of how
to use the NamedNodeMap?
thanks
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12809
    
    5
You could be getting the null pointer if the node list has 0 or 1 items.
NamedNodeMap only appears to require a String when adding a node, what are you going to do with it after you added the node?
Bill
jeff culler
Greenhorn

Joined: Dec 10, 2002
Posts: 10
this was xml that corresponed to a series
of scrollpanes that resided in a JPanel
that used the cardlayout.
I have done some more research on the
NamedNodeMap and the only use I have
seen is to put a node's Attributes in,
to retrieve later.
Can you not simply put a node <a> ,<b> ,<c>
into NamedNodeMap "FirstEditionSections"
Then later retrieve any xml node back by
FirstEditionSections.getNamedItem("a")
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12809
    
    5
Are you trying to use this to modify the DOM or just as a handy way to pass things around?
From the API it looks like you should be able to create a Node, add it to the map and later recover it by name, but I have never done it.
Bill
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: XML dealing with the NamedNodeMap interface