I have a xml file named order-service-api-inbound-sample.xml
who's file path is /home/bs-086/Django/mh-portal/master/portal/portal/endpoints/testdata/order-service-api-inbound-sample.xml
<?xml version="1.0" encoding="UTF-8"?>
<purchaseOrder xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="file:/C:/Users/COMP/Desktop/purchase_order_inbound_schema.xsd">
<customer>
<customer-name>jubydull</customer-name>
<customer-address1>Bangladesh</customer-address1>
<customer-address2>dhaka</customer-address2>
<customer-city>dhaka</customer-city>
<customer-state></customer-state>
<customer-zip>1205</customer-zip>
<customer-country>Bangladesh</customer-country>
</customer>
</purchaseOrder>
I have a model class named models.py who's file path is /home/bs-086/Django/mh-portal/master/portal/portal/endpoints/models.py
from __future__ import unicode_literals
from django.db import models
class Customer(models.Model):
name = models.CharField(max_length=120)
address1 = models.CharField(max_length=120)
address2 = models.CharField(max_length=120)
city = models.CharField(max_length=50)
state = models.CharField(max_length=50)
zip = models.IntegerField()
country = models.CharField(max_length=50)
def __str__(self):
return self.name
Now I wanna save xml file value to my models. How I can I do that ? I am using postgresql database.