• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2499
  • Last Modified:

XML-0108: (Fatal Error) Start of root element expected.

i ahve a oracle data base
i am trying to Load XMl into the Database

This is my program

import java.sql.*;
import oracle.xml.sql.dml.OracleXMLSave;
import java.util.*;
import oracle.jdbc.driver.*;

public class testInsert
   public static void main(String argv[])
     throws SQLException
     DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
     Connection con = DriverManager.getConnection("jdbc:oracle:thin:@DLS702:1521:OMS", "scott", "tiger");
     OracleXMLSave sav = new OracleXMLSave(con, "emp");

this is the xml
<?xml version="1.0" >
   <ROW num="1">
      <HIREDATE>6/9/1981 0:0:0</HIREDATE>
   <ROW num="2">
      <HIREDATE>11/17/1981 0:0:0</HIREDATE>
   <ROW num="3">
      <HIREDATE>1/23/1982 0:0:0</HIREDATE>

how ever when i run it i get this error
<Line 1, Column 1>: XML-0108: (Fatal Error) Start of root element expected.
Exception in thread "main" oracle.xml.sql.OracleXMLSQLException: Start of root element expected.
        at oracle.xml.sql.dml.OracleXMLSave.saveXML(OracleXMLSave.java:2204)
        at oracle.xml.sql.dml.OracleXMLSave.insertXML(OracleXMLSave.java:1276)
        at testInsert.main(testInsert.java:14)

what could be the reason and if any solution?
  • 2
  • 2
1 Solution
I don't know if this is a question typo but :-

<?xml version="1.0" >

should read :-

<?xml version="1.0"?>

Note the second question mark.
violet1306Author Commented:
i tried  this , it didn't work  ?

is it because of the oracle version that i am using?
Ooops, missed it first time round.

The method insertXML with a *string* parameter expects an XML document in the string. The overloaded insertXML method does NOT take a filename. You must create a java.io.InputStream object and pass that instead.
violet1306Author Commented:
thanx it worked

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now