Skip to Content
author's profile photo Former Member
Former Member

PBDOM - A little help

I am reverting my XML parsings from Visual Studio to PB 11.5.1

I have some quite huge XMLs and I trying to understand how PBDOM works (and have very little time to do so 😊 ).

Below is a tiny bit of an XML that I need to parse.

Could you provide my some sample code (just the beginning of a parse into variables) in order to understand practically PBDOM's philosophy?

Thanx in advance!




<RoomRate NumberOfUnits="1" RatePlanCode="XXX1" RoomTypeCode="YYY2">


<Rate EffectiveDate="2013-05-22" ExpireDate="2013-05-23" RateTimeUnit="Day" UnitMultiplier="1">

<Base AmountAfterTax="140.00" CurrencyCode="USD"/>


<Rate EffectiveDate="2013-05-23" ExpireDate="2013-05-24" RateTimeUnit="Day" UnitMultiplier="1">

<Base AmountAfterTax="120.00" CurrencyCode="USD"/>






<GuestCount Age="1" Count="1"/>


<TimeSpan End="2013-05-24" Start="2013-05-22"/>

<Total AmountAfterTax="280.00" CurrencyCode="USD"/>

<BasicPropertyInfo CompanyCode="XXX"/>



<Text>This is a test comment !@ $%^&*()123</Text>





Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on May 19, 2013 at 12:59 PM

    Hi Pano.

    I wonder if there is a problem with content in <comment> <text>.


    Add a comment
    10|10000 characters needed characters exceeded

    • Once you've corrected the reserved character, you could use something like the following to parse the document:

      pbdom_builder          builder     pbdom_document     documentpbdom_element      rootpbdom_element      ldom_childelements[]pbdom_attribute     ldom_effdatepbdom_attribute     ldom_expdatepbdom_attribute     ldom_aftertaxpbdom_attribute     ldom_currencypbdom_element          baseinteger                    li_count, li_indexstring                         ls_messagebuilder = CREATE PBDOM_BUILDERtry       //Create a DOM document from the XML file     document = builder.BuildFromFile ( "document.xml" )           //Get a handle to the root element     root = document.GetRootElement()      document.GetElementsByTagName ( "Rate", ldom_childelements[] )          li_count = UpperBound ( ldom_childelements[] )     FOR li_index = 1 TO li_count          ldom_effdate = ldom_childelements[li_index].getattribute( "EffectiveDate" )          ldom_expdate = ldom_childelements[li_index].getattribute( "ExpireDate" )          base = ldom_childelements[li_index].getchildelement( "Base" )          ldom_aftertax = base.getattribute( "AmountAfterTax" )          ldom_currency = base.getattribute( "CurrencyCode" )          ls_message += "From " + ldom_effdate.gettext( ) + " to " + ldom_expdate.gettext() + " the rate is " + ldom_aftertax.gettext() + " " + ldom_currency.gettext() + "~r~n"     NEXT          MessageBox ( "Rates", ls_message )     catch ( PBDOM_Exception except )     MessageBox ("Exception Occurred", except.Text )finally     Destroy builderend try
  • author's profile photo Former Member
    Former Member
    Posted on May 19, 2013 at 12:20 PM


    Check out my article in PBDJ "Taking PowerBuilder's PBDOM Out for a Spin" Its quite old but should cover the basics.



    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.