The business i work for have a real estate database that exports XML files to other large real estate websites but also exports generic XML files which we would like to use to populate and update our Drupal website which uses the rListing module. Apparently an XML file is generated for each property along with copies of jpegs which is then packaged into a zip file (one zip for each property). I don't know how to write PHP or MySQL from scatch but i am able to modify working examples to a certain extent, so where should i start in trying to accomplish this? From what i have read, the first part involves turning the XML data into an array and the second part would involve inserting the data into the appropriate tables. I also read that SimpleXML function might be usable. A new XML file will be generated each time a new property is created or an existing one is updated so it would be great if i could automate this process somehow, maybe with a cron job?
This is a sample of the XML file layout;
<!-- Contact Details -->
<!ELEMENT Contact ( ContactName,
BHPhone?,
AHPhone?,
Mobile?,
Email?,
UpdateStatus,
UpdateTime )>
<!ATTLIST Contact ContactID CDATA #REQUIRED >
<!ELEMENT ContactName ( #PCDATA ) >
<!ELEMENT BHPhone ( #PCDATA ) >
<!ELEMENT AHPhone ( #PCDATA ) >
<!ELEMENT Mobile ( #PCDATA ) >
<!ELEMENT Email ( #PCDATA ) >
<!-- Property Details -->
<!ELEMENT Property ( ListingType?,
SaleAuthority?,
StreetNumber?,
StreetName?,
Suburb?,
Postcode?,
State?,
Municipality?,
EstateName?,
EstateStage?,
Zone?,
StreetDirectory?,
MapPage?,
MapReference?,
AddressDisplayType?,
BuildingType?,
PropertyType?,
LandFrontage?,
LandWidthRear?,
LandDepthLeft?,
LandDepthRight?,
LandCrossover?,
LandArea?,
BuildingArea?,
NewlyBuilt?,
Rent?,
RentPeriod?,
DateAvailable?,
SalePrice?,
PriceView?,
DisplayPrice?,
Outgoings?,
CommReturn?,
LeaseEndDate?,
AuctionDate?,
AuctionLocation?,
UnderOffer?,
SoldPrice?,
SoldDate?,
AdvHeading?,
AdvDescription?,
AdvNotes?,
ContactID?,
Features?,
Inspections?,
ExternalLinks?,
Images?,
UpdateStatus,
UpdateTime )>
<!ATTLIST Property PropertyID CDATA #REQUIRED >
<!-- Listing -->
<!ELEMENT ListingType EMPTY >
<!ATTLIST ListingType Type ( Rent |
Sale ) #REQUIRED >
<!ELEMENT SaleAuthority EMPTY > <!-- Sale Only -->
<!ATTLIST SaleAuthority Type ( Auction |
Sale |
Exclusive |
Multilist |
Conjunction |
Open |
Tender |
EOI ) #REQUIRED >
<!-- Address -->
<!ELEMENT StreetNumber ( #PCDATA ) >
<!ELEMENT StreetName ( #PCDATA ) >
<!ELEMENT Suburb ( #PCDATA ) >
<!ELEMENT Postcode ( #PCDATA ) >
<!ELEMENT State ( #PCDATA ) >
<!ELEMENT Municipality ( #PCDATA ) > <!-- Sale Only -->
<!ELEMENT EstateName ( #PCDATA ) > <!-- Sale Only -->
<!ELEMENT EstateStage ( #PCDATA ) > <!-- Sale Only -->
<!ELEMENT Zone ( #PCDATA ) > <!-- Sale Only -->
Could anyone explain the process involvement in terms a newbie would understand, supply a piece of code to get started with or maybe point me to something existing which might work? I think this job is above my current skill level but would like to give it a try before outsourcing it so any help would be great.
Thank you,
Joshua Howell
Comments
Does anyone know if it's
Does anyone know if it's even possible to import XML data into a MySQL database using PHP?
Could someone please suggest
Could someone please suggest a starting point? Perhaps a module which parses XML? Anything?
feedapi maybe
feedapi maybe www.drupal.org/project/feedapi?
Greetings, Martijn
Parse XML with PHP into MySQL data
I needed to get a newsfeed to import into a database. Unfortunately not to familiar with XML other than its basic structure and xml PHP functions seemed very complex. So I came up with a hack that does the job. Most newsfeeds are based on tags and often this is the data that one wants. So the following basically allows you to collect a newsfeed and store it in your database. I run the program with cron, thus now its automatically done.
I'm into dating sites. This code runs on my black dating site and my filipino dating site. Hope the above code helps someone - who needs a simple solution to what can be very complex!
Alex.