Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
ysj
Creator
Creator

XML load error

Hi,

I am trying create reload the dashboard using below condition but not able to do that.

getting below error:

XML document must have a top level element.


Dashboard script Script:


LET vFilePath='\TaskLogIndex\TaskLogIndex_*.xml';

LET vSize =FileSize('$(vFilePath)');  //test the file size

IF vSize > 3000  THEN

LOAD

LogID,

    TaskName,

    Date,

    Time,

    ClusterID,

    FullLogPath,

    FileSize() as fsz

FROM $(vFilePath)(XmlSimple, Table is [Root/LogIndex]);

ENDIF

Thank you,

YJ

6 Replies
Anil_Babu_Samineni

This error occurs when you have extra Tag in your XML code?

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
ysj
Creator
Creator
Author

Thank you anil,

Could you please help me.

I want to load file which is greater than 3 KB but my IF condition doesnt work properly.

please provide your thoughts.

Anil_Babu_Samineni

Try this?

LET vSize = filesize(myfile);

IF '$(vSize)' > 3000 THEN

  LOAD * FROM myfile;

ENDIF


So, In your expression you may forget this?

LET vFilePath='\TaskLogIndex\TaskLogIndex_*.xml';

LET vSize =FileSize('$(vFilePath)');  //test the file size

IF '$(vSize)' > 3000  THEN

LOAD

LogID,

    TaskName,

    Date,

    Time,

    ClusterID,

    FullLogPath,

    FileSize() as fsz

FROM $(vFilePath)(XmlSimple, Table is [Root/LogIndex]);

ENDIF

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
avinashelite

IF $(vSize) > 3000 then


...


ENDIF

jonathandienst
Partner - Champion III
Partner - Champion III

In spite of the previous comments, this syntax is correct, so changing it is not necessary:

IF vSize > 3000  THEN


The error you are getting is that the XML file is not well-formed as it lacks a root (or top-level) element. A well-formed XML dopcument will have the layout


<?xml version="1.0" ?>

<rootnode>

  <elementnode></elementnode>

  <elementnode></elementnode>

  ...

</rootnode>

Your document may be lacking the header node and/or root node

https://www.google.co.za/search?source=hp&q=well-formed+XML&oq=well-formed+XML

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Clever_Anjos
Employee
Employee

You probably are trying to load a corrupted file, would you mind posting it?