Alpha Video Training
Results 1 to 6 of 6

Thread: Xbasic XMLParser

  1. #1
    Member
    Real Name
    Miles Nolan
    Join Date
    Jan 2008
    Posts
    265

    Default Xbasic XMLParser

    Hi

    I having a little trouble understanding the Xbasic XML parser and how to get contents of my XML file into variables

    Below is a sample of my XML and I need to assign the values of customer, customerID, datebooked etc into variables.

    Please can someone help with the correct syntax ?

    <bookings customer="Forrest" customerid="17354782" datebooked="2019-05-06 11:13:23" id="9349208">
    <elements>
    <element engine="CelebrityCruises" id="2361209" status="Booked" type="Cruise" />
    </elements>
    </bookings>

    thanks
    john

  2. #2
    Member Corelius's Avatar
    Real Name
    Cornelius Koempel
    Join Date
    May 2005
    Location
    Germany, Duisburg
    Posts
    173

  3. #3
    Member
    Real Name
    Miles Nolan
    Join Date
    Jan 2008
    Posts
    265

    Default Re: Xbasic XMLParser

    Hi Cornelius

    Thanks for replying I was following the 1st page and it wasnt helping fully :-(

    thanks
    john

  4. #4
    "Certified" Alphaholic
    Real Name
    David Kates
    Join Date
    Apr 2008
    Location
    Unionville, ON
    Posts
    7,623

    Default Re: Xbasic XMLParser

    Turn your XML into an XBasic dot variable... and then it will be easier to get what you need.

    Code:
    dim propXML as p
    *PROPERTY_FROM_XML(myXML,propXML)
    Then you can do this to get your element id...

    Code:
    var id as c
    id = propXML.bookings.elements.element.id
    and this to get your customer id...

    Code:
    var custid as c
    propXML.bookings.customerid

  5. #5
    Member
    Real Name
    Miles Nolan
    Join Date
    Jan 2008
    Posts
    265

    Default Re: Xbasic XMLParser

    Hi David

    Thanks for the code , I actually have several booking elements in my XML each time I get the data as below

    <results>
    <bookings customer="Forrest" customerid="17354782" datebooked="2019-05-06 11:43:47" id="9349337">
    <elements>
    <element engine="ManualElement" id="2249024" status="Booked" type="Flight" />
    <element engine="ManualElement" id="2249025" status="Booked" type="Flight" />
    </elements>
    </bookings>
    <bookings customer="Harrison" customerid="17355191" datebooked="2019-05-06 12:28:00" id="9349547">
    <elements>
    <element engine="ManualElement" id="2361294" status="Booked" type="Cruise" />
    </elements>
    </bookings>
    <bookings customer="Hodgetts" customerid="15325539" datebooked="2019-05-06 13:01:51" id="9349716">
    <elements>
    <element engine="ManualElement" id="2361337" status="Booked" type="Cruise" />
    </elements>
    </bookings>
    <bookings customer="Forrest" customerid="17354782" datebooked="2019-05-06 13:43:06" id="9349941">
    <elements>
    <element engine="ManualElement" id="1696296" status="Booked" type="Transfer" />
    <element engine="ManualElement" id="1696297" status="Booked" type="Transfer" />
    </elements>
    </bookings>

    So would there be a way to find each one ?

    thanks

    john

  6. #6
    "Certified" Alphaholic
    Real Name
    David Kates
    Join Date
    Apr 2008
    Location
    Unionville, ON
    Posts
    7,623

    Default Re: Xbasic XMLParser

    There's probably a few ways to do this... here's one. Loop through your property variable...

    Code:
    dim propXML as p
    *PROPERTY_FROM_XML(myXML,propXML)
    
    dim custid as c
    for i = 1 to propXML.results.size()
    	custid = propXML.results[i].customerid
    next i
    Note: The code I posted previously had errors in it. I re-typed it from the interactive window and typed "var" instead of "dim"

Similar Threads

  1. Xbasic Function to convert VBA to Xbasic
    By KYBiggs in forum Application Server Version 10 - Web/Browser Applications
    Replies: 3
    Last Post: 08-22-2017, 09:21 PM
  2. Replies: 23
    Last Post: 02-25-2016, 12:02 PM
  3. XBASIC Conversion to Version 11's XBASIC, Action Scripting, Et Cetera
    By sgerber in forum Alpha Five Version 11 - Desktop Applications
    Replies: 14
    Last Post: 08-31-2012, 01:16 PM
  4. Correct way of writing: XBasic or Xbasic
    By Marcel Kollenaar in forum Alpha Five Version 5
    Replies: 25
    Last Post: 07-22-2004, 07:21 AM
  5. Xbasic run in editor -v- Xbasic run from button
    By Colin Goss in forum Alpha Five Version 4
    Replies: 7
    Last Post: 01-11-2002, 05:59 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •