4 Replies Latest reply: Dec 5, 2011 9:14 AM by vin2k4u RSS

    Adding Childe Node to the XML

    vin2k4u Community Member

      Hello Geeks,

       

      Need your help on solving the below issue.

       

      Am using Adobe Livecycle Workbench ES2 for creating a Process.

       

      The requirement is to Add a Child Node to the XML.

       

      <helpUrls>
                <
      HelpUrl>
                     <
      Name>BugReport</Name>
                     <
      url>C:\BugRep.exe</url>
                </
      HelpUrl>
      </
      helpUrls>

      Need to add Child Node

       

      <helpUrls>
                <
      HelpUrl>
                     <
      Name>BugReport</Name>
                     <
      url>C:\BugRep.exe</url>
                </
      HelpUrl>

                <HelpUrl>
                     <
      Name>IssueReport</Name>
                     <
      url>C:\IssueRep.exe</url>
                </
      HelpUrl>

      </helpUrls>

       

      The Schema Looks as below

      <xs:element name="helpUrls">

      <xs:complexType>

         <xs:sequence maxOccurs="unbounded">

          <xs:element name="HelpUrl">

           <xs:complexType>

            <xs:sequence maxOccurs="unbounded">

             <xs:element name="Name" type="xs:string" />

             <xs:element name="url" type="xs:string" />

            </xs:sequence>

           </xs:complexType>

         </xs:element>

        </xs:sequence>

      </xs:complexType>

      </xs:element>

       

      Thanks in advance

       

      Regards

      Darsh

        • 1. Re: Adding Childe Node to the XML
          $Nith$ Community Member

          This you cannot do in a direct way.

           

          You can add the node <HelpUrl with a different name for example <TempUrl> and then rename the tag name into HelpUrl using XSLT activity. Otherwise the latest node will overwrite the existing HelpUrl node.

           

          Nith

          • 2. Re: Adding Childe Node to the XML
            vin2k4u Community Member

            Hello Nith,

             

            Loads of thanks for you suggestions.. Am not that good in XLST, can you let me know how can i go about renaming the Tags Process Design.

             

            Darsh

            • 3. Re: Adding Childe Node to the XML
              $Nith$ Community Member

              A Sample XM File after adding a <temp> tag would look like:

               

              <root><HelpUrl>some URL1</HelpUrl><HelpUrl>some URL2</HelpUrl><temp>New URL</temp></root>

              The XSL used to rename the above XML is as follows:

               

              <?xml version="1.0"?>

              <xsl:stylesheet version="1.0"

              xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

              <xsl:template match="/">

              <root>

                    <xsl:for-each select="root/HelpUrl">

                                  <HelpUrl>

                                            <xsl:value-of select="."/>

                      </HelpUrl>

                    </xsl:for-each>

                    <xsl:for-each select="root/temp">

                      <HelpUrl>

                                  <xsl:value-of select="."/>

                        </HelpUrl>

                    </xsl:for-each>

              </root>

              </xsl:template>

              </xsl:stylesheet>

               

              I hope you can understand from the above example on how to rename a tag using XLST.

               

              Send me your email address so that I can send you the sample process I tried for you.

               

              Nith

              nith.igate@gmai.com

              • 4. Re: Adding Childe Node to the XML
                vin2k4u Community Member

                Hello Nith

                 

                Thanks a lot you can mail me @ vinooon@gmail.com..

                 

                Darsh