Thanks Tom, I have set up a way to extract the elements I want with
xmltodict and played with lxml.objectify last night and that would work as
well.

But what exactly in django models am I using to bring in the data?

Sayth
On 15/05/2014 1:13 am, "Tom Evans" <[email protected]> wrote:

> On Tue, May 13, 2014 at 8:40 PM, Sayth Renshaw <[email protected]>
> wrote:
> > Can I ask for some assistance please.
> >
> > For my project I will need to upate the database from an external xml
> file
> > consistently. The xml is like this one
> > http://old.racingnsw.com.au/Site/_content/racebooks/20140515GOSF0.xml
> > If i have create my model objects, most of which will have a direct
> > correlation to the xml file, but there will be extra model objects and
> > fields relating to user input. How can I do updates to my database via
> xml.
> >
> > There are 2 docs I have been reviewing
> >
> https://docs.djangoproject.com/en/1.6/howto/initial-data/#providing-initial-data-with-fixtures
> > and https://docs.djangoproject.com/en/1.6/topics/serialization/.
> >
> > The guides talk about creating a fixture but I am not sure it is
> appropriate
> > exactly and I am unsure from the guide how I would setup a mapping so
> that
> > the xml data went to the correct model object.
> > How do I do this?
> >
>
> I don't think you want fixtures, even though there are XML fixtures.
> This is basically a data feed which periodically you wish to import in
> to your own database. Fixtures are normally exports of your own
> database. I think it would be very difficult to ensure that your
> database always matches the contents of an XML file produced by a 3rd
> party.
>
> You could use xslt to transform the 3rd party xml in to the right
> format for an xml serialisation, but that would involve using xslt.
>
> What I would do is write a management command that parses the XML (I
> like lxml), and then iterates through it, using xpath to pull out
> relevant parts of the doc, and then use standard django models to
> create this data in the database, taking care not to insert duplicate
> data when it exists in both DB and XML.
>
> Cheers
>
> Tom
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/TZ2GbmlVk1o/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAFHbX1KCPYxxL%3Duj2CQkX1EiC5Y%3D-DsBSfOqm5YykbxXWT%2B_dA%40mail.gmail.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAN2of00-Lcv6VAeL0Lv%3Dbi7HniBB_YuzitWwy%3DsWiA0g3u0TnQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to