You are here:  » format string


format string

Submitted by Bangkok Bob on Wed, 2006-01-04 05:48 in

Hi,

Could you let me know the correct format string for the XML example (I tried the format string below without success -- just a blank page).

xml|DataSet/diffgr/NewDataSet/DATA/xs:complexType/xs:sequence/

The data I want to extract is within the NewDataSet boundary.

?xml version="1.0" encoding="utf-8"?
DataSet xmlns="http://www.precisionreservations.com/PRWebServ/getHotelInformation"
  xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
    xs:element name="NewDataSet" msdata:IsDataSet="true"
      xs:complexType
        xs:choice maxOccurs="unbounded"
          xs:element name="DATA"
            xs:complexType
              xs:sequence
                xs:element name="Hotel_name" type="xs:string" minOccurs="0" /
                xs:element name="City_id" type="xs:int" minOccurs="0" /
                xs:element name="City_name" type="xs:string" minOccurs="0" /
                xs:element name="Country_id" type="xs:int" minOccurs="0" /
                xs:element name="Country_name" type="xs:string" minOccurs="0" /
                xs:element name="Continent_id" type="xs:int" minOccurs="0" /
                xs:element name="Continent_name" type="xs:string" minOccurs="0" /
                xs:element name="Area_id" type="xs:int" minOccurs="0" /
                xs:element name="Area_name" type="xs:string" minOccurs="0" /
                xs:element name="Hotel_address_i" type="xs:string" minOccurs="0" /
                xs:element name="Hotel_address_ii" type="xs:string" minOccurs="0" /
                xs:element name="Hotel_postal_code" type="xs:string" minOccurs="0" /
                xs:element name="Area_name1" type="xs:string" minOccurs="0" /
                xs:element name="Hotel_room_number" type="xs:string" minOccurs="0" /
                xs:element name="hotel_enable_flag" type="xs:boolean" minOccurs="0" /
                xs:element name="Hotel_description" type="xs:string" minOccurs="0" /
                xs:element name="Star_rating" type="xs:double" minOccurs="0" /
                xs:element name="hotel_public_notes" type="xs:string" minOccurs="0" /
                xs:element name="Formerly_name" type="xs:string" minOccurs="0" /
                xs:element name="hc_hotel_id" type="xs:int" minOccurs="0" /
                xs:element name="Has_new_map" type="xs:int" minOccurs="0" /
                xs:element name="country_name1" type="xs:string" minOccurs="0" /
                xs:element name="hotel_postal_code1" type="xs:string" minOccurs="0" /
                xs:element name="hotel_photo_flag" type="xs:boolean" minOccurs="0" /
                xs:element name="Min_rate" type="xs:decimal" minOccurs="0" /
              /xs:sequence
            /xs:complexType
          /xs:element
        /xs:choice
      /xs:complexType
    /xs:element
  /xs:schema
  diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1"
    NewDataSet xmlns=""
      DATA diffgr:id="DATA1" msdata:rowOrder="0"
        Hotel_nameAmora Tapae/Hotel_name
        City_id7401/City_id
        City_nameChiang Mai/City_name
        Country_id106/Country_id
        Country_nameThailand/Country_name
        Continent_id2/Continent_id
        Continent_nameAsia/Continent_name
        Area_id20542/Area_id
        Area_nameCity Center/Area_name
        Hotel_address_i22 Chaiyaphum Road, Tambol Chiangmoi, Amphur Muang /Hotel_address_i
        Hotel_address_ii /
        Hotel_postal_code50300/Hotel_postal_code
        Area_name1Chiang Mai - City Center/Area_name1
        Hotel_room_number201/Hotel_room_number
        hotel_enable_flagtrue/hotel_enable_flag
        Hotel_descriptionOpened in 2002, the Rydges Amora Tapae Hotel Chiang Mai is conveniently located at Tahpae Gate, Chiang Mai's famous entrance gate into the city. The hotel is only 10 minutes away from Chiang Mai International Airport and 15 minutes away from the Night Bazaar market. Suitable for both business and leisure travelers, the Rydges Tapae Chiang Mai has 204 rooms fitted with all of the amenities, facilities and levels of comfort offered at a hotel of the same class, including a fitness center, a business center, a swimming pool and a bar and restaurant. The hotel maintains the meticulous standards required by travel and tour operators worldwide. For your reservation at the Rydges Amora Tapae Hotel Chiang Mai, please select the dates of your stay and complete our secure online booking form./Hotel_description
        Star_rating4/Star_rating
        hotel_public_notes /
        Formerly_nameRydges Amora Tapae/Formerly_name
        hc_hotel_id0/hc_hotel_id
        Has_new_map2/Has_new_map
        country_name1Thailand/country_name1
        hotel_postal_code150300 /hotel_postal_code1
        hotel_photo_flagtrue/hotel_photo_flag
        Min_rate29.0000/Min_rate
      /DATA
    /NewDataSet
  /diffgr:diffgram
/DataSet

Submitted by support on Wed, 2006-01-04 09:58

Hi Bob,

The following format string should do what you want:

xml|DataSet/diffgr:diffgram/NewDataSet/DATA/

Demo Link (will be deleted shortly)

Submitted by Bangkok Bob on Wed, 2006-01-04 11:29

Hi David,

Many thanks for your quick reply with format string, demo link, and PHP code builder.

I have now extracted the data into MySQL database. At first, I had MySQL error problem until I changed one line. I don't know enough about MySQL to determine reasons, but it works OK now.

changed from:
INSERT INTO table SET
to:
INSERT INTO `table` SET

Thanks again for your support and a wizard product.

Later,

Bangkok Bob