"" />

  1. Ong Chin Keat
  2. PowerBuilder
  3. Sunday, 7 July 2024 10:08 AM UTC

hi all,

I'm BuilFromFile command a load a XML file into PBDOM document (lpbdom_Doc1)and replace all those related value. After that I'm exporting it into a string with command

"ls_xmlsigned =  lpbdom_Doc1.SaveDocumentIntoString();"  The string ls_xmlsigned look like this :  

 

Then I'm import this XML into another (lpbdom_Doc2) XML document's element with command ap_element.AddContent(ls_xmlsigned). Using the same method I'm exporting the content into another string ls_xml but the sting become like this : 

"ls_xml =  lpbdom_Doc2.SaveDocumentIntoString();" 

 

Please advise what's going wrong. 

NOTE : I'm using PB2022R2 Runtime 22.1.0.2828

 

thanks

Dev Ong

 

René Ullrich Accepted Answer Pending Moderation
  1. Tuesday, 9 July 2024 05:34 AM UTC
  2. PowerBuilder
  3. # 1

Here is a short example that adds elements from one list in a XML to list in another XML.

PBDOM_Builder lpbdom_bldr
PBDOM_Document lpbdom_doc1, lpbdom_doc2
PBDOM_Element lpbdom_rootelem1, lpbdom_rootelem2, lpbdom_list1, lpbdom_list2
PBDOM_Object lpbdom_object_array[]
long ll_i


lpbdom_bldr = Create PBDOM_Builder
lpbdom_doc1 = lpbdom_bldr.BuildFromString ("<Test1><List1><data>ABC Data</data></List1></Test1>")
lpbdom_doc2 = lpbdom_bldr.BuildFromString ("<Test2><List2><data>XYZ Data</data></List2></Test2>")

lpbdom_rootelem2 = lpbdom_doc2.getrootelement ()
lpbdom_list2 = lpbdom_rootelem2.GetChildElement ("List2")
lpbdom_list2.GetContent (lpbdom_object_array[])

lpbdom_rootelem1 = lpbdom_doc1.getrootelement ()
lpbdom_list1 = lpbdom_rootelem1.GetChildElement ("List1")

FOR ll_i = 1 TO UpperBound (lpbdom_object_array)
	lpbdom_object_array[ll_i].Detach()  //detach from parent because it will get a new parent
	lpbdom_list1.AddContent(lpbdom_object_array[ll_i])
NEXT

MessageBox ("", lpbdom_doc1.Savedocumentintostring())
Comment
There are no comments made yet.
René Ullrich Accepted Answer Pending Moderation
  1. Monday, 8 July 2024 05:40 AM UTC
  2. PowerBuilder
  3. # 2

Hi,

If you use AddContent with a string as paramater it adds the content as a text. So all special characters like "<" are converted.

You have to use AddContent with pbdom_object parameter to add a complex xml part. https://docs.appeon.com/pb2022/extension_reference/XREF_99028_AddContent.html#XREF_72321_AddContent_Syntax_1

Use GetContent or GetChildElement to get it from lpndom_doc2.

HTH,

René

Comment
  1. Ong Chin Keat
  2. Tuesday, 9 July 2024 01:42 AM UTC
Dear Rene,



Thanks for advice. I tried but can't get it work. Do you have any example to refer to beside Appeon doc? Especially the "GetChildElements" which don't find any good example at Google.



regards,

Dev Ong.
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.