Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xml.parsers.expat.ExpatError: mismatched tag #11

Open
abubelinha opened this issue Aug 1, 2022 · 1 comment
Open

xml.parsers.expat.ExpatError: mismatched tag #11

abubelinha opened this issue Aug 1, 2022 · 1 comment

Comments

@abubelinha
Copy link

pycatstro v.0.1.3, Python 3.4:

from pycatastro import PyCatastro
PyCatastro.Consulta_RCCOOR("EPSG:4258",40,-4)

output:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "c:\python34\lib\site-packages\pycatastro\__init__.py", line 459, in Consulta_RCCOOR
    return xmltodict.parse(response.content, process_namespaces=False, xml_attribs=False)
  File "c:\python34\lib\site-packages\xmltodict.py", line 378, in parse
    parser.Parse(xml_input, True)
xml.parsers.expat.ExpatError: mismatched tag: line 58, column 4
@raultomasmora
Copy link

Función Consulta_RCCOOR independiente que corrige el error

# corregido del código fuente original
import requests
import xmltodict
def Consulta_RCCOORv2(srs, x, y):
    """A partir de unas coordenadas se obtiene la referencia catastral.

       A partir de unas coordenadas (X e Y) y su sistema de referencia se
       obtiene la referencia catastral de la parcela localizada en ese punto
       así como el domicilio (municipio, calle y número o polígono, parcela y
       municipio).

       :param str,int: Sistema de coordenadas. "EPSG:25830" = proyectado ETRS89 UTM30N, "EPSG:4326" = Geográfico WGS84
       :param str,int,float: Coordenada X
       :param str,int,float: Coordenada Y
       :return: Retorna un diccionario con los datos de la consulta
       :rtype: dict
    """
    params = {
        "Coordenada_X": x, # cambios realizados
        "Coordenada_Y": y}
    if type(srs) == str:
        params["SRS"] = srs
    else:
        params["SRS"] = "EPSG:"+str(srs)
    #url = base_url + "/OVCCoordenadas.asmx?op=Consulta_RCCOOR" # el error está aquí
    base_url = "http://ovc.catastro.meh.es/ovcservweb/OVCSWLocalizacionRC" 
    url = base_url + "/OVCCoordenadas.asmx/Consulta_RCCOOR"  # y se corrige aquí
    response = requests.get(url, params=params)
    return xmltodict.parse(response.content, process_namespaces=False, xml_attribs=False)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants