Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: PB 11.5.1 - get value of an attribute from an xml file

791 views
Skip to first unread message

Arthur Hefti

unread,
Sep 25, 2009, 2:15:02 PM9/25/09
to
Check out my article in PBDJ: "Taking PowerBuilder's PBDOM Out for a
Spin" at http://pbdj.sys-con.com/node/107057.

Regards
Arthur

dchambon wrote:

> Hello,
>
> I'm new to PBDOM object and can't figure out how to read the
> value of an attribute inside an xml files.
>
> here is my code
>
> string ls_MsgBox, ls_FileName,ls_txt_fic
> ,ls_baliseXML,ls_no_ord
> integer li_Counter, li_Files,li_num_fic, li_FileNum
> //
> PBDOM_BUILDER dom_builder
> PBDOM_DOCUMENT dom_doc
> PBDOM_OBJECT dom_obj[]
> PBDOM_ELEMENT dom_element
> PBDOM_ATTRIBUTE dom_attribute[]
> //
> ls_FileName = Space( 255 )
> li_Files = DragQueryFile( handle, -1, ls_FileName, 255 )
> FOR li_Counter = 1 TO li_Files
> ls_FileName = Space( 255 )
> DragQueryFile( handle, li_Counter - 1, ls_FileName, 255)
> //li_FileNum = FileCopy (ls_FileName , "C:\jazz.gif",
> FALSE)
> NEXT
> //
> dom_builder = CREATE PBDOM_BUILDER
> TRY
> // Import File and generate XML Document
> dom_doc = dom_Builder.BuildFromFile(ls_FileName)
> dom_doc.getcontent(dom_obj)
> CATCH (PBDOM_Exception lpbdom_Except)
> MessageBox( "PBDOM_Exception",
> lpbdom_Except.GetExceptionCode())
> RETURN
> END TRY
> ls_no_ord =
> dom_doc.GetRootElement().GetAttribute("no_ord").GetText()
>
>
> Thanks for your help
>
> the xml is attached
>
> Best regards,
> Didier.

dchambon

unread,
Sep 25, 2009, 5:36:05 PM9/25/09
to
Hi arthur,

in fact I started from your article to write my code but as
am new to PBDOM I must have missed something :-(

Can you tell me what's wrong in my code ?

Regards,
Didier.

Arthur Hefti

unread,
Sep 26, 2009, 2:37:02 AM9/26/09
to
Didier

I'm using GetAttributeValue ( ls_Attribute ). You can find the
functions in the HTML Books Chapter 14, PBDOM node objects.

Arthur

dchambon

unread,
Sep 29, 2009, 1:34:27 PM9/29/09
to
Hello,

I still don't figure out how to read attribute :-(

For example I need the value of the attribute "no_ord"

helppppp

regards
Didier

Arthur Hefti

unread,
Sep 30, 2009, 12:06:26 AM9/30/09
to
I gave a look at your XML. You're actually want to read the value of
the element "no_ord" and not an attribute. You have the following
options, where you might make your code more generic.

Arthur

//one option is:
dom_doc.getcontent(dom_obj)
// -> Returns an array of two XML elements (XML and ECO_1702_003272004)
dom_obj[2].getcontent(dom_obj)
// Returns one element (ECO_1702_003272004_row)
dom_obj[1].getcontent(dom_obj)
// Returns your elements (no_ord, .. )
ls_no_ord = dom_obj[1].GetText()

// or you do
dom_element =
dom_doc.GetRootElement().GetChildElement("ECO_1702_003272004_row" )
ls_no_ord = dom_element.GetChildElement("no_ord" ).GetText()

dchambon

unread,
Sep 30, 2009, 8:14:48 AM9/30/09
to
Arthur,

Merci beaucoup !!!

Best regards,
Didier.

0 new messages