# And show all ids print o.id # print etree.tostring(o.xobj , pretty_print = True) o2 = XMLBind(objectify.fromstring(template), namespaces={"ns": "tecan.at.schema.documents"}) for key, value in o2.inspect(unique=True).iteritems(): print key, ":", value # Walker Test with namespace wc = XMLWalker(root) xp = "//ReadingFilter?type=@type" result = wc.walk(XPathAnalyzer(xp, namespaces={"ns": "tecan.at.schema.documents"})) print len(result) print result # Walker Test without namespace root = objectify.fromstring(etree.tostring(objectify.parse("gen.xml"))) wc = XMLWalker(root) xp = "//Well?pos=@Pos/Scan?wave=@WL&val=text()" result = wc.walk(XPathAnalyzer(xp)) print len(result) print result[0]
print o.id # print etree.tostring(o.xobj , pretty_print = True) o2 = XMLBind(objectify.fromstring(template), namespaces={'ns': 'tecan.at.schema.documents'}) for key, value in o2.inspect(unique=True).iteritems(): print key, ":", value # Walker Test with namespace wc = XMLWalker(root) xp = "//ReadingFilter?type=@type" result = wc.walk( XPathAnalyzer(xp, namespaces={'ns': 'tecan.at.schema.documents'})) print len(result) print result # Walker Test without namespace root = objectify.fromstring(etree.tostring(objectify.parse('gen.xml'))) wc = XMLWalker(root) xp = "//Well?pos=@Pos/Scan?wave=@WL&val=text()" result = wc.walk(XPathAnalyzer(xp)) print len(result) print result[0]
'manufacturer_url': '/ManufacturerUrl', 'manufacturer_number': '/PartNumber', 'manufacturer_product_url': '/ProductInformationUrl', 'id_momentum': '/Id', 'plate_height': '/Height', 'plate_length': '/Length', 'plate_width': '/Width', 'stacking_plate_height': '/StackHeight', 'plate_numbering': '/Numbering', 'momentum_grip_force': '/GripForce' } a = '//PlateType?' a += '&'.join([key + "='" + value + "/text()'" if value[0] != '@' else key + "='" + value for key, value in definition.iteritems()]) plates = wk.walk(XPathAnalyzer(a)) for plate in plates: c = Container(plate) c.store() infiles = glob.glob('imports/*.pdfx') for filename in infiles: s = etree.tostring(objectify.parse(filename), pretty_print=True) # s = string.replace(s, '\\', '/') #s = unicodedata.normalize("NFKD", s.encode('utf8')) s = s.encode('ascii', 'ignore').encode('latin-1') s = s.decode('utf-8', 'ignore') s = s.replace('®', '(R)')
'id_momentum': '/Id', 'plate_height': '/Height', 'plate_length': '/Length', 'plate_width': '/Width', 'stacking_plate_height': '/StackHeight', 'plate_numbering': '/Numbering', 'momentum_grip_force': '/GripForce' } a = '//PlateType?' a += '&'.join([ key + "='" + value + "/text()'" if value[0] != '@' else key + "='" + value for key, value in definition.iteritems() ]) plates = wk.walk(XPathAnalyzer(a)) for plate in plates: c = Container(plate) c.store() infiles = glob.glob('imports/*.pdfx') for filename in infiles: s = etree.tostring(objectify.parse(filename), pretty_print=True) # s = string.replace(s, '\\', '/') #s = unicodedata.normalize("NFKD", s.encode('utf8')) s = s.encode('ascii', 'ignore').encode('latin-1') s = s.decode('utf-8', 'ignore') s = s.replace('®', '(R)')
#root = objectify.fromstring(s, parser=None) #root = objectify.parse('filename.xml') root = objectify.fromstring(etree.tostring(objectify.parse('E_PTT_BeamLocation_A12345678W_20140729_225738.xml'))) print etree.tostring(root, pretty_print=True) # root.xpath('//Section/Data/Well/Multiple') # root.xpath('//Section[@Name='Label1']/Data/Well/Multiple') # root.xpath('//Section[@Name='Label1']/Data/Well/Multiple?pos=@MRW_Position') # root.xpath('//Section[@Name='Label1']/Data/Well/Multiple/@MRW_Position') wk = XMLWalker(root) data = wk.walk(XPathAnalyzer("//Section[@Name='Label1']/Data/Well?well=@Pos/Multiple?pos=@MRW_Position&value='/text()'")) print data beams = {} for d in data: p = d['pos'].split(';') if len(p) > 1: if d['well'] not in beams: beams[d['well']] = np.ones([15, 15]) * (-0.1) beams[d['well']][int(p[0]), int(p[1])] = float(d['value']) grayscale = " .:-=+*#%@" gsl = len(grayscale)
#root = objectify.parse('filename.xml') root = objectify.fromstring( etree.tostring( objectify.parse('E_PTT_BeamLocation_A12345678W_20140729_225738.xml'))) print etree.tostring(root, pretty_print=True) # root.xpath('//Section/Data/Well/Multiple') # root.xpath('//Section[@Name='Label1']/Data/Well/Multiple') # root.xpath('//Section[@Name='Label1']/Data/Well/Multiple?pos=@MRW_Position') # root.xpath('//Section[@Name='Label1']/Data/Well/Multiple/@MRW_Position') wk = XMLWalker(root) data = wk.walk( XPathAnalyzer( "//Section[@Name='Label1']/Data/Well?well=@Pos/Multiple?pos=@MRW_Position&value='/text()'" )) print data beams = {} for d in data: p = d['pos'].split(';') if len(p) > 1: if d['well'] not in beams: beams[d['well']] = np.ones([15, 15]) * (-0.1) beams[d['well']][int(p[0]), int(p[1])] = float(d['value']) grayscale = " .:-=+*#%@"