read data from XML file
#1
Hello everyone. I am making an addon to read files that are passed in an XML file. XML structure is very simple

Archivo XML
https://paste.kodi.tv/jimavexizo.kodi

The addon.py where the error arises is this:
Code:
# -*- coding: utf-8 -*-
import sys
import xbmcgui
import xbmcplugin
import xbmc
import os
from urlparse import parse_qsl
from io import open
from bs4 import BeautifulSoup as bs

__url__ = sys.argv[0];
addon_handle  =  int ( sys . argv [ 1 ])

contenido =[]
archivo = open("D:\\Kodi_Listado_Completo.xml", mode="r", encoding="utf-8-sig")
lineas= archivo.readlines()
lineas_modificadas=[]
for i in range(len(lineas)):
    lineas.replace("\\ufeff", "")
    lineas_modificadas.append(lineas[i].strip())
contenido = "".join(lineas_modificadas)
documento = bs(contenido, "xml")
del lineas, lineas_modificadas, contenido

The addon.xml is this:[/i]
Code:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.lacibis" name="Lacibis" version="1.0.0" provider-name="julius">
  <requires>
    <import addon="xbmc.python" version="2.26.0"/>
    <import addon="plugin.video.youtube" version="6.7.0"/>
    <import addon="script.module.beautifulsoup4" version="4.6.2"/>    
  </requires>
  <extension point="xbmc.python.pluginsource" library="addon.py">
    <provides>video</provides>
  </extension>
  <extension point="xbmc.addon.metadata">
    <summary>Lacibis</summary>
    <description>Addon de Cine</description>
    <disclaimer></disclaimer>
    <language></language>
    <platform>all</platform>
    <assets>
      <icon>resources/icon.png</icon>
      <fanart>resources/fanart.jpg</fanart>
    </assets>
  </extension>
</addon>

[i]The kodi.log file is as follows[/i]
https://paste.kodi.tv/cezobopojo.kodi


From what I see it is a failure because KODI does not have a parse installed. I have tried to do the same with ElementTree.ettree but it doesn't give problems with script.module.abi dependency too.
I am a novice in this I would appreciate help. I have searched and tried different options but it doesn't work. Thank you
Reply
#2
'xml' parser in BeautifulSoup4 uses lxml Python parser library. Since it is a binary library it is not included in Kodi. You can use either ElementTree or DOM parser that are included in Python standard library and do not require external dependencies.

Also this line:
lineas.replace("\\ufeff", "")
in your code does not make sense:
a) you are using an escape-encoded Unicode symbol inside a byte string so it is interpreted literally as a sequence of \, u, f, e, f and f English characters. Use Unicode literals (u'') for such cases.
b) you are opening a file in the text mode with utf-8-sig mode so the UTF-8 BOM byte (\uFEFF) is automatically skipped.
c) BOM is inserted only at the beginning of a file, not at each string, so no need to remove it from each string (which should be done in the the binary reading mode anyway).
Reply
 
Thread Rating:
  • 0 Vote(s) - 0 Average



Logout Mark Read Team Forum Stats Members Help
read data from XML file00
This forum uses Lukasz Tkacz MyBB addons.