Create a xml document


#1

hi !

i tried the giraffe example to do a xml document with visual basic 6

[quote] // create an outer node called "ANIMALS"
XmlElement animalsList (“ANIMALS”);

for (int i = 0; i < numAnimals; ++i)
{
    // create an inner element..
    XmlElement* giraffe = new XmlElement ("GIRAFFE");

    giraffe->setAttribute ("name", "nigel");
    giraffe->setAttribute ("age", 10);
    giraffe->setAttribute ("friendly", true);

    // ..and add our new element to the parent node
    animalsList.addChildElement (giraffe);
}

// now we can turn the whole thing into a text document..
String myXmlDoc = animalsList.createDocument (String::empty);

[/quote]

but i get this :

[quote]error C2664: ‘void __thiscall juce::XmlElement::setAttribute(const unsigned short *const ,const class juce::String &)’ : cannot convert parameter 1 from ‘char [5]’ to 'const un
signed short *const '[/quote]


#2

This error is caused by using the unicode build of juce and your application isn’t unicode

you have a few options:
rebuild juce as not unicode (its a flag in config.h)
build your app as unicode

or

use the T("") macro to convert your strings to whatever type of strings juce is using.

ie:
giraffe->setAttribute (T(“name”), T(“nigel”));


#3

put T( ) around all your strings… so “GIRAFFE” would be written as T(“GIRAFFE”)


#4

It works !
Thanks for your help !


#5