Basic XML File Creation Help

Hey Guys,

again and back to the Problem =) .
I think i have a main Problem with the file creation.

I insert in my Project just the Example from the JUCE XMLElement Class:
/* EXAMPLE STARTS HERE
// 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());
*/ EXAMPLE ENDS HERE

As i understood, this example would write me an XMLDocument in which includes the Attributes from the Giraffe.

The Code compiles, but i cant find any XML File or Document on my Mac.
Then i thought, i need to write that XMLDocument in an File.

So i thought i need to add the writeToFile function at the end, cause it says it would write the Element to an File as an XML Document.
My Idea:
animalsList.writeToFile();

but what to insert in the brackets??? And where does the programm know, where to store the file? Do i need to define a directory path before i can write something?

Greetings,
Manuel

1 Like