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

How to add a prefix to an PBDOM element

I have an recursive function to read XML documents using PBDOM

Now I want to add some new elements with or without an prefix depending on the original xml document.

everything looks like ok but I miss the xml-prefix in the new added elemens in the new document.


ls_type = pbdom_obj_array[ll_loop].getname()



CASE "nichtangeboten"

SELECT "lv_lohn", "lv_sonstiges", "lv_betrag"

INTO :lv_lohn, :lv_sonstiges, :lv_betrag

FROM "lvpositionen" WHERE "lv_nummer" = :onlv_daten.lv_nummer and "lv_baustellenr" = :onlv_daten.projektnr;

if NOT isNull(lv_betrag) and lv_betrag <> 0 then


//ns_prefix = pbdom_obj.GetQualifiedName()

PBDOM_ELEMENT pbdom_elem0, pbdom_elem1, pbdom_elem2, pbdom_elem3, pbdom_elem4

pbdom_elem0 = Create PBDOM_ELEMENT

ns_prefix = pbdom_obj.GetNamespacePrefix ()

//ns_prefix examle: on

ns_uri = pbdom_obj.GetNamespaceUri()

pbdom_elem1 = Create PBDOM_ELEMENT

pbdom_elem2 = Create PBDOM_ELEMENT

pbdom_elem3 = Create PBDOM_ELEMENT

pbdom_elem4 = Create PBDOM_ELEMENT

if isNUll(lv_lohn) then lv_lohn = 0.00

if isNUll(lv_sonstiges) then lv_sonstiges = 0.00

if isNUll(lv_betrag) then lv_betrag = 0.00


//what I want is <on:preis>10.00</on:preis>

//but I get <preis>10.00</preis>

//wrong, adds an attribute not the prefix :-(

/* if ns_prefix > ' ' and ns_uri > ' ' then

pbdom_elem0.AddNamespaceDeclaration(ns_prefix, ns_uri)

end if



pbdom_elem1.AddContent(f_changecharacters(string(lv_lohn, "0.00"), ',', '.'))

pbdom_elem0.AddContent (pbdom_elem1)


pbdom_elem2.AddContent(f_changecharacters(string(lv_sonstiges, "0.00"), ',', '.'))

pbdom_elem0.AddContent (pbdom_elem2)


pbdom_elem3.AddContent(f_changecharacters(string(lv_betrag, "0.00"), ',', '.'))

pbdom_elem0.AddContent (pbdom_elem3)

pbdom_obj.AddContent (pbdom_elem0)


pbdom_elem4.AddContent(f_changecharacters(string(lv_betrag, "0.00"), ',', '.'))

pbdom_obj.AddContent (pbdom_elem4)

destroy pbdom_elem0

destroy pbdom_elem1

destroy pbdom_elem2

destroy pbdom_elem3

destroy pbdom_elem4

end if

CASE "preis"


Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Posted on May 12, 2015 at 03:23 PM

    I think you have to go with SetNamespace (), after doing an AddNamespaceDeclaration() at a higher level).



    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.