kandi background
Explore Kits

objectify | simplest convenient interface to the Google Cloud Datastore | Database library

 by   objectify Java Version: Current License: MIT

 by   objectify Java Version: Current License: MIT

Download this library from

kandi X-RAY | objectify Summary

objectify is a Java library typically used in Database applications. objectify has no bugs, it has no vulnerabilities, it has build file available, it has a Permissive License and it has high support. You can download it from GitHub.
Objectify is a Java data access API specifically designed for the Google Cloud Datastore (aka the Google App Engine Datastore). It occupies a "middle ground"; easier to use and more transparent than JDO or JPA, but significantly more convenient than the low-level API libraries that Google provides. Objectify is designed to make novices immediately productive yet also expose the full power of the Datastore. Important note about versions: Objectify v5 and prior use the Google App Engine API for Java and therefore can only be used within Google App Engine Standard. Objectify v6+ uses the Cloud Datastore API and can be used from anywhere - GAE Standard, GAE Flex, GCE, or outside Google Cloud entirely. See the FAQ for more information.
Support
Support
Quality
Quality
Security
Security
License
License
Reuse
Reuse

kandi-support Support

  • objectify has a highly active ecosystem.
  • It has 699 star(s) with 156 fork(s). There are 62 watchers for this library.
  • It had no major release in the last 12 months.
  • There are 123 open issues and 291 have been closed. On average issues are closed in 53 days. There are 18 open pull requests and 0 closed requests.
  • It has a negative sentiment in the developer community.
  • The latest version of objectify is current.
objectify Support
Best in #Database
Average in #Database
objectify Support
Best in #Database
Average in #Database

quality kandi Quality

  • objectify has 0 bugs and 0 code smells.
objectify Quality
Best in #Database
Average in #Database
objectify Quality
Best in #Database
Average in #Database

securitySecurity

  • objectify has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • objectify code analysis shows 0 unresolved vulnerabilities.
  • There are 0 security hotspots that need review.
objectify Security
Best in #Database
Average in #Database
objectify Security
Best in #Database
Average in #Database

license License

  • objectify is licensed under the MIT License. This license is Permissive.
  • Permissive licenses have the least restrictions, and you can use them in most projects.
objectify License
Best in #Database
Average in #Database
objectify License
Best in #Database
Average in #Database

buildReuse

  • objectify releases are not available. You will need to build from source code and install.
  • Build file is available. You can build the component from source.
  • Installation instructions are not available. Examples and code snippets are available.
  • objectify saves you 9023 person hours of effort in developing the same functionality from scratch.
  • It has 18464 lines of code, 1759 functions and 375 files.
  • It has low code complexity. Code complexity directly impacts maintainability of the code.
objectify Reuse
Best in #Database
Average in #Database
objectify Reuse
Best in #Database
Average in #Database
Top functions reviewed by kandi - BETA

kandi has reviewed objectify and discovered the below as its top functions. This is intended to give you an instant insight into objectify implemented functionality, and help decide if they suit your requirements.

  • Make sure that the value can be filtered by the given value .
  • Load values from the datastore .
  • Returns exact types of the given type .
  • Find key fields in the class hierarchy .
  • Compare two KeyElement
  • Converts an inner class to an inner class .
  • Flushes all operations .
  • Gets all of the specified keys .
  • Saves the entity .
  • Gets statistics .

objectify Key Features

Objectify lets you persist, retrieve, delete, and query your own typed objects.

Objectify surfaces all native datastore features, including batch operations, queries, transactions, asynchronous operations, and partial indexes.

Objectify provides type-safe key and query classes using Java generics.

Objectify provides a human-friendly query interface.

Objectify can automatically cache your data in memcache for improved read performance.

Objectify can store polymorphic entities and perform true polymorphic queries.

Objectify provides a simple, easy-to-understand transaction model.

Objectify provides built-in facilities to help migrate schema changes forward.

Objectify provides thorough documentation of concepts as well as use cases.

Objectify has an extensive test suite to prevent regressions.

Features

copy iconCopydownload iconDownload
@Entity
class Car {
    @Id String vin; // Can be Long, long, or String
    String color;
}
  
ofy().save().entity(new Car("123123", "red")).now();
Car c = ofy().load().type(Car.class).id("123123").now();
ofy().delete().entity(c);

lxml get element names dynamically even for the ones which are nested

copy iconCopydownload iconDownload
etree.QName(element).localname
print(event, etree.QName(element).localname, element.text) 
-----------------------
etree.QName(element).localname
print(event, etree.QName(element).localname, element.text) 

Parse xml file in pandas

copy iconCopydownload iconDownload
myDict = {}
#register the namespace
ns = {'xx': 'http://www.dmg.org/PMML-4_4'}

#you could collapse the next two into one line, but I believe it's clearer this way
rt = root.xpath('//xx:RegressionTable[.//xx:NumericPredictor]',namespaces=ns)[0]
nps = rt.xpath('./xx:NumericPredictor',namespaces=ns)

for np in nps:
    myDict[np.attrib['name']]=np.attrib['coefficient']
myDict

Parse xml file with python

copy iconCopydownload iconDownload
import xml.etree.ElementTree as ET
from typing import Dict

xml = '''<BSB>
    <APPLSUMMARY>
        <MAIN W="S1" X="{ND}"/>
        <COUNTS Z="0" AB="0" BB="0" CB="0" DB="0" EB="0" FB="0" GB="{ND}"/>
        <SCOTDEBT OQB="{ND}"/>
        <NOTICES HB="0" IB="3"/>
        <SUB_BLOCKS C="3" D="3" E="1" F="0"/>
        <ALIAS_NO UPB="0" VPB="{ND}" WPB="0"/>
        <ASSOC_NO DD="0" ED="0" AC="0"/>
        <ALERTSUMM PB="0" QB="0" RB="{ND}" SB="{ND}" TB="{ND}" UB="{ND}"/>
        <HHOSUMM BC="{ND}" RGB="{ND}"/>
        <TPD INB="{ND}" JNB="{ND}" KNB="{ND}" LNB="{ND}"/>
        <OCCUPANCY AD="1"/>
        <DECEASED LQB="1" FCC="{ND}" GCC="{ND}" HCC="{ND}" ICC="{ND}"/>
        <IMPAIRED MQB="0"/>
        <ACTIVITY JCC="{ND}" KCC="{ND}" LCC="{ND}"/>
        <ADVERSE MCC="{ND}" HHC="{ND}"/>
    </APPLSUMMARY>
</BSB>'''


def _clean_dict(attributes: Dict) -> Dict:
    result = {}
    for k, v in attributes.items():
        if v[0] == '{':
            val = v[1:-1]
        else:
            val = v
        result[k] = val
    return result


data = []
root = ET.fromstring(xml)
for d in root.findall('.//DECEASED'):
    data.append(_clean_dict(d.attrib))
print(data)
[{'LQB': '1', 'FCC': 'ND', 'GCC': 'ND', 'HCC': 'ND', 'ICC': 'ND'}]
-----------------------
import xml.etree.ElementTree as ET
from typing import Dict

xml = '''<BSB>
    <APPLSUMMARY>
        <MAIN W="S1" X="{ND}"/>
        <COUNTS Z="0" AB="0" BB="0" CB="0" DB="0" EB="0" FB="0" GB="{ND}"/>
        <SCOTDEBT OQB="{ND}"/>
        <NOTICES HB="0" IB="3"/>
        <SUB_BLOCKS C="3" D="3" E="1" F="0"/>
        <ALIAS_NO UPB="0" VPB="{ND}" WPB="0"/>
        <ASSOC_NO DD="0" ED="0" AC="0"/>
        <ALERTSUMM PB="0" QB="0" RB="{ND}" SB="{ND}" TB="{ND}" UB="{ND}"/>
        <HHOSUMM BC="{ND}" RGB="{ND}"/>
        <TPD INB="{ND}" JNB="{ND}" KNB="{ND}" LNB="{ND}"/>
        <OCCUPANCY AD="1"/>
        <DECEASED LQB="1" FCC="{ND}" GCC="{ND}" HCC="{ND}" ICC="{ND}"/>
        <IMPAIRED MQB="0"/>
        <ACTIVITY JCC="{ND}" KCC="{ND}" LCC="{ND}"/>
        <ADVERSE MCC="{ND}" HHC="{ND}"/>
    </APPLSUMMARY>
</BSB>'''


def _clean_dict(attributes: Dict) -> Dict:
    result = {}
    for k, v in attributes.items():
        if v[0] == '{':
            val = v[1:-1]
        else:
            val = v
        result[k] = val
    return result


data = []
root = ET.fromstring(xml)
for d in root.findall('.//DECEASED'):
    data.append(_clean_dict(d.attrib))
print(data)
[{'LQB': '1', 'FCC': 'ND', 'GCC': 'ND', 'HCC': 'ND', 'ICC': 'ND'}]

Python xml duplicate a specific sub element and all sub elements and change its name

copy iconCopydownload iconDownload
from lxml import etree
import copy

s = """<main>
 <head>
   <elem1>
    <sub1>Example</sub1>
   </elem1>
 </head>
</main>"""

file = etree.fromstring(s)
head = file.find("head")
for elem1 in file.findall(".//elem1"):
    dupe = copy.deepcopy(elem1) #copy <elem1> node
    dupe.tag = "new_copy_element"
    head.append(dupe) #insert the new node

print(etree.tostring(file,pretty_print=True, encoding=str))

Objectify xml string with dashes in tags and attributes names

copy iconCopydownload iconDownload
from xml.etree import ElementTree as ET

xml = """<foo-foo name="example" foo-description="description">
                   <bar doc-name="name" />
                    <test tag="test" />
                </foo-foo>"""

foo_foo = ET.fromstring(xml)
print(f'name: {foo_foo.attrib["name"]}')
print(f'bar dic name: {foo_foo.find("bar").attrib["doc-name"]}')
print(f'test tag: {foo_foo.find("test").attrib["tag"]}')
name: example
bar dic name: name
test tag: test
-----------------------
from xml.etree import ElementTree as ET

xml = """<foo-foo name="example" foo-description="description">
                   <bar doc-name="name" />
                    <test tag="test" />
                </foo-foo>"""

foo_foo = ET.fromstring(xml)
print(f'name: {foo_foo.attrib["name"]}')
print(f'bar dic name: {foo_foo.find("bar").attrib["doc-name"]}')
print(f'test tag: {foo_foo.find("test").attrib["tag"]}')
name: example
bar dic name: name
test tag: test
-----------------------
from lxml import etree
from lxml import objectify

xml_string = """<root>
                   <foo-foo name="example" foo-description="description">
                       <bar doc-name="name" />
                       <test tag="test" />
                    </foo-foo>
                </root>"""

doc = etree.fromstring(xml_string)
for tag in doc.iter():
    if '-' in tag.tag:
        tag.tag = tag.tag.replace('-', '_')

obj = objectify.fromstring(etree.tostring(doc))

Lxml object not found in lxml tree during search after adding in it in tree

copy iconCopydownload iconDownload
new_element_string = "<AR-PACKAGE xmlns:None='http://autosar.org/schema/r4.0'><SHORT-NAME xmlns:None='http://autosar.org/schema/r4.0'></SHORT-NAME>{0}</AR-PACKAGE>".format("AUTOSAR_Platform")
new_element_string = "<AR-PACKAGE xmlns:None='http://autosar.org/schema/r4.0'><SHORT-NAME xmlns:None='http://autosar.org/schema/r4.0'>{0}</SHORT-NAME></AR-PACKAGE>".format("AUTOSAR_Platform")

new_element_string = "<AR-PACKAGE xmlns='http://autosar.org/schema/r4.0'><SHORT-NAME>{0}</SHORT-NAME></AR-PACKAGE>".format("AUTOSAR_Platform")
-----------------------
new_element_string = "<AR-PACKAGE xmlns:None='http://autosar.org/schema/r4.0'><SHORT-NAME xmlns:None='http://autosar.org/schema/r4.0'></SHORT-NAME>{0}</AR-PACKAGE>".format("AUTOSAR_Platform")
new_element_string = "<AR-PACKAGE xmlns:None='http://autosar.org/schema/r4.0'><SHORT-NAME xmlns:None='http://autosar.org/schema/r4.0'>{0}</SHORT-NAME></AR-PACKAGE>".format("AUTOSAR_Platform")

new_element_string = "<AR-PACKAGE xmlns='http://autosar.org/schema/r4.0'><SHORT-NAME>{0}</SHORT-NAME></AR-PACKAGE>".format("AUTOSAR_Platform")
-----------------------
new_element_string = "<AR-PACKAGE xmlns:None='http://autosar.org/schema/r4.0'><SHORT-NAME xmlns:None='http://autosar.org/schema/r4.0'></SHORT-NAME>{0}</AR-PACKAGE>".format("AUTOSAR_Platform")
new_element_string = "<AR-PACKAGE xmlns:None='http://autosar.org/schema/r4.0'><SHORT-NAME xmlns:None='http://autosar.org/schema/r4.0'>{0}</SHORT-NAME></AR-PACKAGE>".format("AUTOSAR_Platform")

new_element_string = "<AR-PACKAGE xmlns='http://autosar.org/schema/r4.0'><SHORT-NAME>{0}</SHORT-NAME></AR-PACKAGE>".format("AUTOSAR_Platform")

Delete Element from XML file using python

copy iconCopydownload iconDownload
from lxml import objectify, etree

cda_tree = etree.parse('data.xml')
cda_root = cda_tree.getroot()

ns = {
    'hl7': 'urn:hl7-org:v3',
}

for node in cda_tree.xpath('//hl7:component/hl7:structuredBody', namespaces=ns):
    node.getparent().remove(node)

cda_tree.write('newXML.xml')

<ClinicalDocument
    xmlns="urn:hl7-org:v3"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <component>
    <structuredBody>
    ...
    ...
    </structuredBody>
  </component>
</ClinicalDocument>
<ClinicalDocument xmlns="urn:hl7-org:v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <component>
    </component>
</ClinicalDocument>
-----------------------
from lxml import objectify, etree

cda_tree = etree.parse('data.xml')
cda_root = cda_tree.getroot()

ns = {
    'hl7': 'urn:hl7-org:v3',
}

for node in cda_tree.xpath('//hl7:component/hl7:structuredBody', namespaces=ns):
    node.getparent().remove(node)

cda_tree.write('newXML.xml')

<ClinicalDocument
    xmlns="urn:hl7-org:v3"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <component>
    <structuredBody>
    ...
    ...
    </structuredBody>
  </component>
</ClinicalDocument>
<ClinicalDocument xmlns="urn:hl7-org:v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <component>
    </component>
</ClinicalDocument>
-----------------------
from lxml import objectify, etree

cda_tree = etree.parse('data.xml')
cda_root = cda_tree.getroot()

ns = {
    'hl7': 'urn:hl7-org:v3',
}

for node in cda_tree.xpath('//hl7:component/hl7:structuredBody', namespaces=ns):
    node.getparent().remove(node)

cda_tree.write('newXML.xml')

<ClinicalDocument
    xmlns="urn:hl7-org:v3"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <component>
    <structuredBody>
    ...
    ...
    </structuredBody>
  </component>
</ClinicalDocument>
<ClinicalDocument xmlns="urn:hl7-org:v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <component>
    </component>
</ClinicalDocument>

NoSuchMethodError for com.google.api.Service.hasQuota after appengineDeploy

copy iconCopydownload iconDownload
glcoud update components

java.lang.NoSuchMethodError: com.google.api.client.http.HttpTransport.isMtls()Z

copy iconCopydownload iconDownload
<dependency>
    <groupId>com.google.apis</groupId>
    <artifactId>google-api-services-storage</artifactId>
    <version>v1-rev20190129-1.26.0</version>
</dependency>
 mvn clean package
-----------------------
<dependency>
    <groupId>com.google.apis</groupId>
    <artifactId>google-api-services-storage</artifactId>
    <version>v1-rev20190129-1.26.0</version>
</dependency>
 mvn clean package
-----------------------
<dependency>
    <groupId>com.google.cloud</groupId>
    <artifactId>google-cloud-bigquery</artifactId>
    <version>1.127.10</version>
</dependency>
<dependency>
    <groupId>com.google.http-client</groupId>
    <artifactId>google-http-client</artifactId>
    <version>1.39.1</version>
</dependency>
<dependency>
    <groupId>com.google.api-client</groupId>
    <artifactId>google-api-client</artifactId>
    <version>1.31.2</version>
</dependency>
-----------------------
<dependency>
    <groupId>com.google.cloud</groupId>
    <artifactId>google-cloud-bigquery</artifactId>
    <version>1.127.10</version>
</dependency>
<dependency>
    <groupId>com.google.http-client</groupId>
    <artifactId>google-http-client</artifactId>
    <version>1.39.1</version>
</dependency>
<dependency>
    <groupId>com.google.api-client</groupId>
    <artifactId>google-api-client</artifactId>
    <version>1.31.2</version>
</dependency>

Sorting XML using values in python etree

copy iconCopydownload iconDownload
root = objectify.fromstring(xml)
root.labels = sorted(root.labels, key=lambda tag: tag.fullName)
from lxml import objectify, etree

xml = '''<CustomLabels xmlns="http://soap.sforce.com/2006/04/metadata">
    <labels>
        <fullName>ZZZAManualQuote</fullName>
        <value>This is a manual quote.</value>
        <language>en_US</language>
        <protected>false</protected>
        <shortDescription>Manual Quote</shortDescription>
    </labels>
    <labels>
        <fullName>AnAutoQuote</fullName>
        <value>This is an automatically generated quote.</value>
        <language>en_US</language>
        <protected>false</protected>
        <shortDescription>Automatic Quote</shortDescription>
    </labels>
    <labels>
        <fullName>AManualQuote</fullName>
        <value>This is a manual quote.</value>
        <language>en_US</language>
        <protected>false</protected>
        <shortDescription>Manual Quote</shortDescription>
    </labels>
</CustomLabels>'''

root = objectify.fromstring(xml)
root.labels = sorted(root.labels, key=lambda tag: tag.fullName)

print(etree.tostring(root, pretty_print=True).decode('utf-8'))
<CustomLabels xmlns="http://soap.sforce.com/2006/04/metadata">
  <labels>
    <fullName>AManualQuote</fullName>
    <value>This is a manual quote.</value>
    <language>en_US</language>
    <protected>false</protected>
    <shortDescription>Manual Quote</shortDescription>
  </labels>
  <labels>
    <fullName>AnAutoQuote</fullName>
    <value>This is an automatically generated quote.</value>
    <language>en_US</language>
    <protected>false</protected>
    <shortDescription>Automatic Quote</shortDescription>
  </labels>
  <labels>
    <fullName>ZZZAManualQuote</fullName>
    <value>This is a manual quote.</value>
    <language>en_US</language>
    <protected>false</protected>
    <shortDescription>Manual Quote</shortDescription>
  </labels>
</CustomLabels>
-----------------------
root = objectify.fromstring(xml)
root.labels = sorted(root.labels, key=lambda tag: tag.fullName)
from lxml import objectify, etree

xml = '''<CustomLabels xmlns="http://soap.sforce.com/2006/04/metadata">
    <labels>
        <fullName>ZZZAManualQuote</fullName>
        <value>This is a manual quote.</value>
        <language>en_US</language>
        <protected>false</protected>
        <shortDescription>Manual Quote</shortDescription>
    </labels>
    <labels>
        <fullName>AnAutoQuote</fullName>
        <value>This is an automatically generated quote.</value>
        <language>en_US</language>
        <protected>false</protected>
        <shortDescription>Automatic Quote</shortDescription>
    </labels>
    <labels>
        <fullName>AManualQuote</fullName>
        <value>This is a manual quote.</value>
        <language>en_US</language>
        <protected>false</protected>
        <shortDescription>Manual Quote</shortDescription>
    </labels>
</CustomLabels>'''

root = objectify.fromstring(xml)
root.labels = sorted(root.labels, key=lambda tag: tag.fullName)

print(etree.tostring(root, pretty_print=True).decode('utf-8'))
<CustomLabels xmlns="http://soap.sforce.com/2006/04/metadata">
  <labels>
    <fullName>AManualQuote</fullName>
    <value>This is a manual quote.</value>
    <language>en_US</language>
    <protected>false</protected>
    <shortDescription>Manual Quote</shortDescription>
  </labels>
  <labels>
    <fullName>AnAutoQuote</fullName>
    <value>This is an automatically generated quote.</value>
    <language>en_US</language>
    <protected>false</protected>
    <shortDescription>Automatic Quote</shortDescription>
  </labels>
  <labels>
    <fullName>ZZZAManualQuote</fullName>
    <value>This is a manual quote.</value>
    <language>en_US</language>
    <protected>false</protected>
    <shortDescription>Manual Quote</shortDescription>
  </labels>
</CustomLabels>
-----------------------
root = objectify.fromstring(xml)
root.labels = sorted(root.labels, key=lambda tag: tag.fullName)
from lxml import objectify, etree

xml = '''<CustomLabels xmlns="http://soap.sforce.com/2006/04/metadata">
    <labels>
        <fullName>ZZZAManualQuote</fullName>
        <value>This is a manual quote.</value>
        <language>en_US</language>
        <protected>false</protected>
        <shortDescription>Manual Quote</shortDescription>
    </labels>
    <labels>
        <fullName>AnAutoQuote</fullName>
        <value>This is an automatically generated quote.</value>
        <language>en_US</language>
        <protected>false</protected>
        <shortDescription>Automatic Quote</shortDescription>
    </labels>
    <labels>
        <fullName>AManualQuote</fullName>
        <value>This is a manual quote.</value>
        <language>en_US</language>
        <protected>false</protected>
        <shortDescription>Manual Quote</shortDescription>
    </labels>
</CustomLabels>'''

root = objectify.fromstring(xml)
root.labels = sorted(root.labels, key=lambda tag: tag.fullName)

print(etree.tostring(root, pretty_print=True).decode('utf-8'))
<CustomLabels xmlns="http://soap.sforce.com/2006/04/metadata">
  <labels>
    <fullName>AManualQuote</fullName>
    <value>This is a manual quote.</value>
    <language>en_US</language>
    <protected>false</protected>
    <shortDescription>Manual Quote</shortDescription>
  </labels>
  <labels>
    <fullName>AnAutoQuote</fullName>
    <value>This is an automatically generated quote.</value>
    <language>en_US</language>
    <protected>false</protected>
    <shortDescription>Automatic Quote</shortDescription>
  </labels>
  <labels>
    <fullName>ZZZAManualQuote</fullName>
    <value>This is a manual quote.</value>
    <language>en_US</language>
    <protected>false</protected>
    <shortDescription>Manual Quote</shortDescription>
  </labels>
</CustomLabels>

Community Discussions

Trending Discussions on objectify
  • lxml get element names dynamically even for the ones which are nested
  • Parse xml file in pandas
  • Objectify with Firestore native - no matching index found
  • Parse xml file with python
  • Python xml duplicate a specific sub element and all sub elements and change its name
  • Objectify xml string with dashes in tags and attributes names
  • Datastore emulator returns 'Only ancestor queries are allowed inside transactions’. Doesn't it support Firestore in Datastore mode?
  • Lxml object not found in lxml tree during search after adding in it in tree
  • Delete Element from XML file using python
  • NoSuchMethodError for com.google.api.Service.hasQuota after appengineDeploy
Trending Discussions on objectify

QUESTION

lxml get element names dynamically even for the ones which are nested

Asked 2022-Feb-25 at 10:15

I have the following xml

<?xml version="1.0" encoding="UTF-8"?><gudid xmlns="http://www.fda.gov/cdrh/gudid" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0" xsi:schemaLocation="http://www.fda.gov/cdrh/gudid gudid.xsd">
<device xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.fda.gov/cdrh/gudid">
  <publicDeviceRecordKey>7c36b446-020c-44ab-9ce7-a85387467e0f</publicDeviceRecordKey>
  <publicVersionStatus>New</publicVersionStatus>
  <deviceRecordStatus>Published</deviceRecordStatus>
  <identifiers>
    <identifier>
      <deviceId>M930756120810</deviceId>
      <deviceIdType>Primary</deviceIdType>
      <deviceIdIssuingAgency>HIBCC</deviceIdIssuingAgency>
      <containsDINumber xsi:nil="true"></containsDINumber>
      <pkgQuantity xsi:nil="true"></pkgQuantity>
      <pkgDiscontinueDate xsi:nil="true"></pkgDiscontinueDate>
      <pkgStatus xsi:nil="true"></pkgStatus>
      <pkgType xsi:nil="true"></pkgType>
    </identifier>
  </identifiers>
  <brandName>Life Instruments</brandName>
  <gmdnTerms>
    <gmdn>
      <gmdnPTName>Orthopaedic knife</gmdnPTName>
      <gmdnPTDefinition>A hand-held manual surgical instrument designed for cutting/shaping bone during an orthopaedic surgical intervention. It is typically a heavy, one-piece instrument with a sharp, single-edged, strong cutting blade at the distal end available in various shapes and sizes, with a handle at the proximal end. It is normally made of high-grade stainless steel. This is a reusable device.</gmdnPTDefinition>
    </gmdn>
  </gmdnTerms>
  <productCodes>
    <fdaProductCode>
      <productCode>LXH</productCode>
      <productCodeName>Orthopedic Manual Surgical Instrument</productCodeName>
    </fdaProductCode>
  </productCodes>
  <deviceSizes/>
  <environmentalConditions/>
</device>
</gudid>

I use lxml to parse this xml

with open("sample.xml", encoding="utf-8") as f:          
    xml = f.read().encode()                              
                                                         
root = objectify.fromstring(xml) 

When I tried to loop over the xml I get the following issue

for event, element in etree.iterwalk(root, events=("start", "end")):   
    if event == "start":                                               
        print(event, element.tag, element.text)   

                 
start {http://www.fda.gov/cdrh/gudid}publicDeviceRecordKey 7c36b446-020c-44ab-9ce7-a85387467e0f
start {http://www.fda.gov/cdrh/gudid}publicVersionStatus New
start {http://www.fda.gov/cdrh/gudid}deviceRecordStatus Published
start {http://www.fda.gov/cdrh/gudid}identifiers None
....
start {http://www.fda.gov/cdrh/gudid}device None
start {http://www.fda.gov/cdrh/gudid}publicDeviceRecordKey be401033-96bf-46ec-8ac0-b2ce302d2b11
start {http://www.fda.gov/cdrh/gudid}sterilizationMethod Moist Heat or Steam Sterilization

Every element seems to have a namespace which I don't want. I would rather want a flat list from the xml

publicDeviceRecordKey                 deviceId             gmdnPtName .....
7c36b446-020c-44ab-9ce7-a85387467e0f  M930756120810        Orthopaedic knife

How do i get rid of the namespace in the element.tag please ?

ANSWER

Answered 2022-Feb-25 at 10:15

If you want to access the tag name without namespace definition, you can get the localname of the element like

etree.QName(element).localname

You can print the local name and check

print(event, etree.QName(element).localname, element.text) 

Source https://stackoverflow.com/questions/71263321

Community Discussions, Code Snippets contain sources that include Stack Exchange Network

Vulnerabilities

No vulnerabilities reported

Install objectify

You can download it from GitHub.
You can use objectify like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the objectify component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .

Support

Full documentation is available in the Objectify Wiki.

DOWNLOAD this Library from

Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

Explore Related Topics

Share this Page

share link
Compare Database Libraries with Highest Support
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

  • © 2022 Open Weaver Inc.