Convert xml files

Help each other out

Convert xml files

Postby fsamuelsson on Tue Aug 05, 2008 7:15 pm

Hi guys (haven´t seen any girls her yet, but if you are out there hi to you to :)

I have spent a couple of houres plying with xml files so i can view the contents in xlobby, but this is pretty new to me and the net is full of resources but i don´t have the patient to learn xml from scratch. So i thought i ask a question here. I have an application (logtemp) that can save temp mesurement data in an xml file, but saves it in format so xlobby deletes it contents. So how can i convert the xml file that i have to an format that xlobby can read ? pasting an sample of the xml file generated by the app, thanx in advance :)

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<DATA>
<PROGRAM NAME="LogTemp">
<VERSION>2.21.0.78</VERSION>
</PROGRAM>
<TEMPERATURES>
<SENSOR ROMID="230008012548BF10">
<VALUE>25.06</VALUE>
<DATE>
<YEAR>2008</YEAR>
<MONTH>8</MONTH>
<DAY>4</DAY>
</DATE>
<TIME>
<HOUR>21</HOUR>
<MIN>34</MIN>
<SEC>50</SEC>
</TIME>
</SENSOR>
<SENSOR ROMID="2400080125079E10">
<VALUE>25.56</VALUE>
<DATE>
<YEAR>2008</YEAR>
<MONTH>8</MONTH>
<DAY>4</DAY>
</DATE>
<TIME>
<HOUR>21</HOUR>
<MIN>34</MIN>
<SEC>46</SEC>
</TIME>
</SENSOR>
<SENSOR ROMID="68000801255FF110">
<VALUE>9.25</VALUE>
<DATE>
<YEAR>2008</YEAR>
<MONTH>8</MONTH>
<DAY>4</DAY>
</DATE>
<TIME>
<HOUR>21</HOUR>
<MIN>34</MIN>
<SEC>47</SEC>
</TIME>
</SENSOR>
<SENSOR ROMID="9500080125471810">
<VALUE>24.06</VALUE>
<DATE>
<YEAR>2008</YEAR>
<MONTH>8</MONTH>
<DAY>4</DAY>
</DATE>
<TIME>
<HOUR>21</HOUR>
<MIN>34</MIN>
<SEC>44</SEC>
</TIME>
</SENSOR>
<SENSOR ROMID="F3000801258AD910">
<VALUE>25.56</VALUE>
<DATE>
<YEAR>2008</YEAR>
<MONTH>8</MONTH>
<DAY>4</DAY>
</DATE>
<TIME>
<HOUR>21</HOUR>
<MIN>34</MIN>
<SEC>49</SEC>
</TIME>
</SENSOR>
</TEMPERATURES>
</DATA>
fsamuelsson
 
Posts: 40
Joined: Sun Sep 23, 2007 9:24 pm
Location: Sweden

Re: Convert xml files

Postby Marbles_00 on Tue Aug 05, 2008 8:06 pm

Does the program that creates the database have some sort of editable template? Or is it hardcoded to write the data in that format?

If it does have a template, open it up and compare with a standard xlobby xml file, like music or movies. One thing I did notice in a quick comparision is that the xlobby databases xml files start with <database> then <sortorder>X</sortorder>. Maybe you can seperate each sensor with <item></item>

Another thing that I notice that is different from the xlobby database xml files is that this has the following:
<SENSOR ROMID="230008012548BF10"></SENSOR>

where the xlobby references would be <sensor>230008012548BF10</sensor>.

So something like this may work:
Code: Select all
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<database>
<sortorder>sensor</sortorder>
<item>
     <sensor>230008012548BF10<sensor>
     <value>25.06</value>
     <date>
          <year>2008</year>
          <month>8</month>
          <day>4</day>
     </date>
     <time>
          <hour>21</hour>
          <min>34</min>
          <sec>50</sec>
     </time>
</item>
<item>
     <sensor>2400080125079E10<sensor>
     <value>25.56</value>
     <date>
          <year>2008</year>
          <month>8</month>
          <day>4</day>
     </date>
     <time>
          <hour>21</hour>
          <min>34</min>
          <sec>50</sec>
     </time>
</item>
</database>


You could even add <name></name> and add a name to each sensor then I think you could do a sortorder on the name instead.

There may be a converting program to do it as well, but you would have to do a search (both xlobby plugins and google).

Hope that helps
Marbles_00
 
Posts: 1867
Joined: Wed Apr 06, 2005 12:44 pm
Location: Canada

Re: Convert xml files

Postby m_ski on Wed Aug 06, 2008 11:20 am

Try the attached plugin by an old forum member antipasto (No posts since 2005). I have not used it but it can apparently convert any xml file to xlobby format.
The original download site is now dead so I don't know where antipasto is now. I downloaded this because I thought I may have a use for it one day...
Attachments
xml2xlobby_v1.0.zip
xml to xlobby plugin by antipasto
(11.17 KiB) Downloaded 283 times
m_ski
 
Posts: 204
Joined: Wed Dec 08, 2004 7:57 am
Location: Kent, United Kingdom

Re: Convert xml files

Postby fsamuelsson on Fri Aug 08, 2008 5:33 pm

Thanx alot guys !!

One more problem, i have now spent about 10 houres trying to write an xsl file for the conversion but i still don´t get it quite right som parts is missing from the output xml file so it´s unusable.

So if you or anyone else is handy writing xsl templates you have my promition ;)

what i wan´t is the name and value "fields" in a xlobby database so i can show it. Simple, right, :lol: NOT


?xml version="1.0" encoding="utf-8" standalone="yes"?>
<?xml-stylesheet type="text/xsl" href="logtemp7.xsl"?>
<DATA>
<PROGRAM NAME="LogTemp">
<VERSION>2.21.0.78</VERSION>
</PROGRAM>
<TEMPERATURES>
<SENSOR ROMID="230008012548BF10">
<NAME>230008012548BF10</NAME>
<VALUE>24.94</VALUE>
<DATE>
<YEAR>2008</YEAR>
<MONTH>8</MONTH>
<DAY>8</DAY>
</DATE>
<TIME>
<HOUR>17</HOUR>
<MIN>43</MIN>
<SEC>28</SEC>
</TIME>
</SENSOR>
<SENSOR ROMID="2400080125079E10">
<NAME>2400080125079E10</NAME>
<VALUE>24.63</VALUE>
<DATE>
<YEAR>2008</YEAR>
<MONTH>8</MONTH>
<DAY>8</DAY>
</DATE>
<TIME>
<HOUR>17</HOUR>
<MIN>43</MIN>
<SEC>23</SEC>
</TIME>
</SENSOR>
<SENSOR ROMID="F3000801258AD910">
<NAME>F3000801258AD910</NAME>
<VALUE>24.44</VALUE>
<DATE>
<YEAR>2008</YEAR>
<MONTH>8</MONTH>
<DAY>8</DAY>
</DATE>
<TIME>
<HOUR>17</HOUR>
<MIN>43</MIN>
<SEC>26</SEC>
</TIME>
</SENSOR>
<SENSOR ROMID="9500080125471810">
<NAME>Golv</NAME>
<VALUE>23.75</VALUE>
<DATE>
<YEAR>2008</YEAR>
<MONTH>8</MONTH>
<DAY>8</DAY>
</DATE>
<TIME>
<HOUR>17</HOUR>
<MIN>43</MIN>
<SEC>22</SEC>
</TIME>
</SENSOR>
<SENSOR ROMID="68000801255FF110">
<NAME>Utomhus</NAME>
<VALUE>18.06</VALUE>
<DATE>
<YEAR>2008</YEAR>
<MONTH>8</MONTH>
<DAY>8</DAY>
</DATE>
<TIME>
<HOUR>17</HOUR>
<MIN>43</MIN>
<SEC>25</SEC>
</TIME>
</SENSOR>
</TEMPERATURES>
</DATA>
fsamuelsson
 
Posts: 40
Joined: Sun Sep 23, 2007 9:24 pm
Location: Sweden