XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

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 Dev Shed Forums Sponsor:
  #1  
Old February 23rd, 2004, 02:02 PM
Internment Internment is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 27 Internment User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
re: Tearing my hair out!!!

Hi folks,
I have a parser parsing out CURRENT_TEMP from an XML file at the moment, but when I use the Stringbuffer() method to handle the temperature to pass it into the variable this.currentTemp I don't think it is working. The reason I think this, is that when I do a test on the this.currentTemp variable like so:

if (this.currentTemp == null)
{
System.err.println("currentTemp==null");
systemError();
return;
}

the program prints out currentTemp==null. Anyways, this is the way I have use the Stringbuffer below:



StringBuffer buffer;
String currentTemp;

/**************************************************************************
* The following methods are SAX callback routines. Some of them are empty.
**************************************************************************/
public void setDocumentLocator(Locator locator) { }

/**
* New parsing is started.
*/
public void startDocument() throws SAXException
{
System.out.println("at start of the XML file");
this.currentTemp = null;
}

public void endDocument() throws SAXException
{
System.out.println("at end of the XML file");
}

/**
* Started processing a new element. If the tag is "ROADSURFACE_TEMP",
* prepare a buffer to keep the content.
*/
public void startElement(String name, Attributes atts) throws SAXException
{
if (name.equals("ROADSURFACE_TEMP"))
{
this.buffer = new StringBuffer();
}
}

/**
* An element is just closed. If the element is "CurrTemp",
* copy the content to this.currTemp.
*/
public void endElement(String name) throws SAXException {
if (name.equals("ROADSURFACE_TEMP"))
{
this.currentTemp = this.buffer.toString();
}
}

/**
* Accumulate characters if the buffer has been allocated.
*/
public void characters(char ch[], int start, int length) throws SAXException
{
if (this.buffer != null)
{
//this is just checking if the programs getting this far, which it isn't
System.out.println("hello there");
this.buffer.append(ch, start, length);
System.out.println(this.buffer);
}
}



Any help is very much appreciated.....Thank you in advance!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > re: Tearing my hair out!!!


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 | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway