1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

How to structure a xmlelement/xmlattributes for form

Discussion in 'SQL PL/SQL' started by Laura Lou, Dec 9, 2016.

  1. Laura Lou

    Laura Lou Newly Initiated

    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    30
    Location:
    houston, tx
    Hi,

    I'm new to xmltype. I want to create a form populated with my query data. I just need help with how to add input fields with a certain type and their name/values. For example, I have the following line but it's not working correctly. The database value is appearing outside the input field.

    Code (SQL):
     XMLELEMENT("FORM",
                     XMLELEMENT("TR",
                      XMLELEMENT("TABLE",
                       XMLATTRIBUTES('bgcolor:#eeeeee' AS STYLE),
                       XMLELEMENT("TR",
                        XMLELEMENT("TD",  
                         XMLELEMENT("b", 'Name: ')
                        ),
                        XMLELEMENT("TD",
                         XMLELEMENT("INPUT",
                          XMLELEMENT("NAME", myName)
                         )
                        )                
                       )
                      )
                     )
                   
    Also, if anyone has any reference that might be helpful, I'd appreciate it.

    Thanks
     
  2. raovk13

    raovk13 Active Member

    Messages:
    29
    Likes Received:
    1
    Trophy Points:
    110
    I was working on a task and had similar question. For my reference , prepared one document . Attaching the same, hope it helps.

    Regards,
     
  3. raovk13

    raovk13 Active Member

    Messages:
    29
    Likes Received:
    1
    Trophy Points:
    110
    Xml and xml types reference document..
     

    Attached Files:

  4. krasnoslobodtsev_si

    krasnoslobodtsev_si Forum Genius

    Messages:
    769
    Likes Received:
    148
    Trophy Points:
    830
    Location:
    Russian Federation
  5. David stephan

    David stephan Active Member

    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    55
    Location:
    Germany
    Hey! Check this:


    SELECT XMLELEMENT("name", e.ename) AS employee
    FROM emp e
    WHERE e.empno = 7782;

    EMPLOYEE
    ----------------------------------------------------------------------------------------------------
    <name>CLARK</name>

    1 row selected.

    SQL>
    The XMLELEMENT function can also be used to group together and place a tag around existing XML fragments.

    SELECT XMLELEMENT("employee",
    XMLELEMENT("works_number", e.empno),
    XMLELEMENT("name", e.ename)
    ) AS employee
    FROM emp e
    WHERE e.empno = 7782;

    EMPLOYEE
    ----------------------------------------------------------------------------------------------------
    <employee><works_number>7782</works_number><name>CLARK</name></employee>

    1 row selected.

    SQL>