Creating xml file[question]


#1

Using the code unchanged from JUCE.chm the helper:

// 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);

got problem with:
giraffe->setAttribute (“name”, “nigel”);
giraffe->setAttribute (“age”, 10);
giraffe->setAttribute (“friendly”, true);

VS2005 says: “name” is const char[5] that can’t be converted to const juce::tchar *const…

But it seems to be alright…tchar is just typedefed char…shouldn’t happen…


#2

As a general rule of thumb, I always wrap my string literals with the T macro. eg, replace “name” with T(“name”). See the docs for a further explanation.


#3

no, it’s actually wchar_t, or whatever the platform equivalent is.