Get specific text from xml using python -


i have xml string looks this:

<?xml version="1.0" encoding="utf-8"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/xmlschema" xmlns:geonode="http://www.geonode.org/" xmlns:gml="http://www.opengis.net/gml" elementformdefault="qualified" targetnamespace="http://www.geonode.org/">   <xsd:import namespace="http://www.opengis.net/gml" schemalocation="http://localhost:8080/geoserver/schemas/gml/3.1.1/base/gml.xsd"/>   <xsd:complextype name="test_24type">     <xsd:complexcontent>       <xsd:extension base="gml:abstractfeaturetype">         <xsd:sequence>           <xsd:element maxoccurs="1" minoccurs="0" name="attribute_1" nillable="true" type="xsd:string"/>           <xsd:element maxoccurs="1" minoccurs="0" name="the_geom" nillable="true" type="gml:multilinestringpropertytype"/>         </xsd:sequence>       </xsd:extension>     </xsd:complexcontent>   </xsd:complextype>   <xsd:element name="test_24" substitutiongroup="gml:_feature" type="geonode:test_24type"/> </xsd:schema> 

what want use python in order extract url corresponding xmlns:geonode:

"http://www.geonode.org/" 

i know there library: xml.etree import celementtree et not sure how use in order extract information on element.

the following 1 of ways extract data xml file using xml.etree library , python 2.7. replace xml file name , tag name in corresponding places in code.

import xml.etree.elementtree xt datatree = xt.parse('your_xml_file_name.xml') dataroot = datatree.getroot() geonode = dataroot.find('your_tag_name').text print geonode 

Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -