XML

 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me



Go Back   Tutorialized ForumsWeb Design & DevelopmentXML

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Tutorialized Forums Sponsor:
  #1  
Old March 12th, 2005, 03:43 AM
juvy juvy is offline
Contributing User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 1 juvy New User: is a brand new recruit and a unknown entity at this point. 
Time spent in forums: < 1 sec
Reputation Power: 0
Help!! XML with Java

Hi all!!

I badly need ur help....
what method in java can i used in getting the value in this element:

<Wait>5</Wait>? I need to get the value of 5...I used DOM to access the XML...here is my code for this...

public void readSgData(File oSgFile) throws Exception
{
Document document = null;
DocumentBuilderFactory factory = DocumentBuilderFactory. newInstance();
try
{
DocumentBuilder builder = factory.newDocumentBuilder();
document = builder.parse(oSgFile);
NodeList oNodelist = document.getElementsByTagName("Wait");
for (int i=0; i< oNodelist.getLength();i++)
{
Node oNode = oNodelist.item(i);
System.out.println("Node name: " + oNode.getNodeName());
if(oNode.getNodeType() == Node.ELEMENT_NODE)
{
Element oElem = (Element) oNode;
System.err.println(oElem.toString());
}
System.out.println("Node type: " + oNode.getNodeType());
System.out.println("Node value: " + oNode.getNodeValue());
}
}
catch (SAXException sxe)
{
// Error generated during parsing
Exception x = sxe;
if (sxe.getException() != null)
x = sxe.getException();
x.printStackTrace();
}
catch (ParserConfigurationException pce)
{
// Parser with specified options can't be built
pce.printStackTrace();
}
catch (IOException ioe)
{
// I/O error
ioe.printStackTrace();
}
catch(Exception e)
{
e.printStackTrace();
}
return new EMSSgData(1, 1, 1);
}

and here is my xml file....

<?xml version="1.0" encoding="EUC-JP" ?>
<message>

<Wait>5</Wait>
<Poll>5</Poll>
<NotificationTimer>6</NotificationTimer>
</message>

thanx!!=)

Reply With Quote
  #2  
Old January 14th, 2008, 04:14 PM
sarangi sarangi is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Dec 2007
Posts: 7 sarangi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 56 m 58 sec
Reputation Power: 0
try something like this

oNode.getFirstChild().getNodeValue();

Reply With Quote
Reply

Viewing: Tutorialized ForumsWeb Design & DevelopmentXML > Help!! XML with Java


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.

© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap