Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

XML - change element/node name

Former Member
0 Likes
1,757

Hi,

I'm using this function to generate the data to dom.

CALL FUNCTION 'SDIXML_DATA_TO_DOM'

EXPORTING

NAME = 'ACCESOS'

DATAOBJECT = ACCESOS[]

IMPORTING

DATA_AS_DOM = L_DOM

CHANGING

DOCUMENT = M_DOCUMENT

EXCEPTIONS

ILLEGAL_NAME = 1

OTHERS = 2.

IF SY-SUBRC = 0.

WRITE 'Ok'.

ELSE.

WRITE: 'Err =',

SY-SUBRC.

ENDIF.

My issue is when i'm using this function it will generate the xml in this format

<?xml version="1.0" encoding="utf-8" ?>

- <ACCESOS>

- <item>

- <SOCIO>

<NUMERO>00045050</NUMERO>

<REPOSICION>0</REPOSICION>

<NOMBRE>MOISES MORENO</NOMBRE>

- <TURNOS>

<LU>T1</LU>

<MA>T2</MA>

<MI>T3</MI>

<JU>T4</JU>

<VI>T5</VI>

<SA>T6</SA>

<DO>T7</DO>

</TURNOS>

</SOCIO>

</item>

</ACCESOS>

May I know how could I change the "<item" and "</item>" description to "<testing>" and "</testing>". Kindly help me on this.

Thanks.

2 REPLIES 2
Read only

Former Member
0 Likes
678

Hi

Check this link:

Check this link:

http://www.devguru.com/technologies/xmldom/quickref/node_nodeName.html

Regards

Neha

Edited by: Neha Shukla on Nov 30, 2008 9:51 AM

Read only

uwe_schieferstein
Active Contributor
0 Likes
678

Hello

You can do a simple XML-XML transformation using the following XSLT stylesheet:


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

    <xsl:output encoding="UTF-8" method="xml" indent="yes"/>

    <xsl:template match="*">
        <xsl:apply-templates select="self::*" mode="copy"/>
    </xsl:template>
    
    <xsl:template match="item">
        <xsl:element name="testing">
            <xsl:apply-templates />           
        </xsl:element>
    </xsl:template>

    <xsl:template match="*" mode="copy">
        <xsl:copy>
            <xsl:apply-templates/>
        </xsl:copy>
    </xsl:template>

    <xsl:template match="text()">
        <xsl:value-of select="."/>
    </xsl:template>

</xsl:stylesheet>

Regards

Uwe