XMLPORT Special character with CDATA

kenjeskenjes Member Posts: 76
Hi,

I need a CDATA TAG like this from a XMLport :

<Text><[CDATA[This Is my Cdata text bla bla bla bla]]></Text>

NOT :
<Text><[CDATA[This Is my Cdata text bla bla bla bla]]></Text>

My xmlport replaces < and >

Thanks ..

/Kenneth

Answers

  • kenjeskenjes Member Posts: 76
    Hi

    That's the one I have used :smile:
    //>Descriptions
    CLEAR(LongDescr);
    CR[1] := 13;
    LF[1] := 10;
    
    Item.CALCFIELDS(WebTextDK);
    Item.WebTextDK.CREATEINSTREAM(Istream);
    LongDescr.READ(Istream);
    
    CLEAR(LongDescription);
    IF LongDescr.LENGTH > 0 THEN BEGIN
      LongDescription.ADDTEXT('<![CDATA['+CR+LF);
      LongDescription.ADDTEXT(LongDescr);
      LongDescription.ADDTEXT(CR+LF+']]>');
    END;
    

    And it gives med this :

    <LongDescription><![CDATA[
    Æske m. låg i sæt af 3 Bruges til dekoration eller som opbevaring af kontorartikler eller mindre legetøj og nips
    ]]></LongDescription>

    With the <! and >

    The XMLPORT that replaces the <>

  • kenjeskenjes Member Posts: 76
    Hi again

    I can see the this site convert the character I tried to write back to <> :smile:
          <LongDescription>&lt;![CDATA[
    Æske m. låg i sæt af 3 Bruges til dekoration eller som opbevaring af kontorartikler eller mindre legetøj og nips
    ]]&gt;</LongDescription>
    
  • kenjeskenjes Member Posts: 76
    Hi

    I have solved it with a little dotnet.

    First I export the XML file with <LongDescription> as a normal text. (BIGTEXT)

    Then when file is closed I use this code :
    Xml := Xml.XmlDocument();
    Xml.Load('C:\TEMP\Products.xml');
    XMLRootNode := Xml.DocumentElement;
    FOREACH XmlNode IN XMLRootNode.SelectNodes('/root/Products/Product/LongDescription') DO
      BEGIN
        innertext := XmlNode.InnerText;
        IF innertext <> '' THEN BEGIN  
          newCDATA := XmlNode.OwnerDocument.CreateCDataSection(innertext);
          XmlNode.InnerText := '';
          XmlNode.AppendChild(newCDATA);
        END;
      END;
    

    Variables defined :
    Xml DotNet System.Xml.XmlDocument.'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
    XmlNode DotNet System.Xml.XmlNode.'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
    XMLRootNode DotNet System.Xml.XmlNode.'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
    innertext Text
    newCDATA DotNet System.Xml.XmlCDataSection.'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

    My solution, :smile:
    I anyone runs into same issue.

    Thanks.

Sign In or Register to comment.