  | Mailing List | | Home | | Forum Home | | JBoss - Java Application Server | | Struts - A MVC web framework | | Tomcat - JSP/Servlet container | | iText - An open source PDF Java Library | | JDOM - JDOM XML Parser | | J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition | | J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog | | Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology | | JSP - A mailing list about Java Server Pages specification and reference | |
Struts & Hibernate
|
|
|
  | | | jdom | jdom 2004-04-01 - By M.Novosselov
Back Hi, I got a few surprises while testing my program. I wrote test XML file in notepad and saved it using UTF-8 (See http://UTF-8.ora-code.com) encoding. To my surprise I got a parsing exception thrown by SAXBuilder: root-element is missing. When I saved same file using other encodings - everything worked fine (btw file with UTF-8 (See http://UTF-8.ora-code.com) encoding had size 3 bytes bigger than others). But, though file was parsed and I could get root's children by calling getChildren(), my atempt to get root's child by using getChild(String name) failed, method returned a null pointer. Same for getAttribute(String name), though getAttributes() worked fine. In both cases there was only one element and one attribute. I also tried XML file that was written by some one using XML editor (do not know which one) and had encoding UTF-8 (See http://UTF-8.ora-code.com) (<?xml version.... encoding="UTF-8 (See http://UTF-8.ora-code.com)"?>) to my surprise (again) it worked. Program did not throw parsing exception, as with file that was written using notepad and saved with UTF-8 (See http://UTF-8.ora-code.com) encoding. So I'm wondering if it's just me or there is bug, or something. Thanks
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=Content-Type content="text/html; charset=iso-8859 (See http://iso-8859.ora-code.com)-1"> <META content="MSHTML 6.00.2800.1400" name=GENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=#ffffff> <DIV><FONT face=Arial size=2>Hi,</FONT></DIV> <DIV><FONT face=Arial size=2>I got a few surprises while testing my program. I wrote test XML file in notepad and saved it using UTF-8 (See http://UTF-8.ora-code.com) encoding. To my surprise I got a parsing exception thrown by SAXBuilder:</FONT></DIV> <DIV><FONT face=Arial size=2>root-element is missing. When I saved same file using other encodings - everything worked fine (btw file with UTF-8 (See http://UTF-8.ora-code.com) encoding had size 3 bytes bigger than others). But, though file was parsed and I could get root's children by calling getChildren(), my atempt to get root's child by using getChild(String name) failed, method returned a null pointer.</FONT></DIV> <DIV><FONT face=Arial size=2>Same for getAttribute(String name), though getAttributes() worked fine. In both cases there was only one element and one attribute. I also tried XML file that was written by some one using XML editor (do not know which one) and had encoding UTF-8 (See http://UTF-8.ora-code.com)</FONT></DIV> <DIV><FONT face=Arial size=2>(<?xml version.... encoding="UTF-8 (See http://UTF-8.ora-code.com)"?>) to my surprise (again) it worked. Program did not throw parsing exception, as with file that was written using notepad and saved with UTF-8 (See http://UTF-8.ora-code.com) encoding.</FONT></DIV> <DIV><FONT face=Arial size=2></FONT><FONT face=Arial size=2>So I'm wondering if it's just me or there is bug, or something.</FONT></DIV> <DIV><FONT face=Arial size=2>Thanks</FONT></DIV> <DIV><FONT face=Arial size=2></FONT> </DIV></BODY></HTML>
|
|
 |