Thread: XML Problems

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2004
    Posts
    3
    Rep Power
    0

    XML Problems


    Heres the deal,

    I have some var strings, say:

    var
    cheddar, pepparoni, cheese, bbqsauce, onions: string;

    then i want to convert these into a structured xml document.

    heres what i have so far


    XMLDocument2.DocumentElement := XMLDocument2.CreateElement('pizza',''); <--creates the root node right? -->

    anyone know what is the XMLdocument command to create the following structure in xml:

    <pizza>
    <toppings>
    <toppingA> cheddar </toppingA>
    <toppingB> pepparoni </toppingB>
    <toppingC> cheese </toppingC>
    <toppingD> bbqsauce </toppingD>
    <toppingE> onions </toppingE>
    </toppings>
    </pizza>

    Any help really appreciated!
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2004
    Posts
    1
    Rep Power
    0

    Thumbs up


    Hi,

    //create root node
    Root := XMLDocument2.Node.AddChild('Pizza');

    ChildLevel1 := Root.AddChild('Toppings');
    ChildLevel2 := ChildLevel1.AddChild('ToppingsA');
    ChildLevel2.Text := cheddar;
    ChildLevel2 := ChildLevel1.AddChild('ToppingsB');
    ChildLevel2.Text := pepparoni;
    ChildLevel2 := ChildLevel1.AddChild('ToppingsC');
    ChildLevel2.Text := cheese;
    ChildLevel2 := ChildLevel1.AddChild('ToppingsD');
    ChildLevel2.Text := bbqsauce;
    ChildLevel2 := ChildLevel1.AddChild('ToppingsE');
    ChildLevel2.Text := onions;

    XMLDocument2.SaveToFile(GetCurrentDir + '\filename.xml');

    Hope this helps.

IMN logo majestic logo threadwatch logo seochat tools logo