[vtkusers] problem with XML export

Sebastien Valette sebastien.valette at creatis.insa-lyon.fr
Fri Jun 27 07:30:49 EDT 2008


Hi,

I am trying to export some data in XML format using vtkXMLDataElement 
and vtkXMLUtilities.
Here is the code I tried:

#include <vtkXMLDataElement.h>
#include <vtkXMLUtilities.h>

int main( int argc, char *argv[] )
{
    // create the element
    vtkXMLDataElement *Element=vtkXMLDataElement::New();
    Element->SetAttribute("Name", "My Element");
    Element->SetIntAttribute("Number of items", 25);

    // (1) one query
    int NumItems;
    cout<<Element->GetNumberOfAttributes()<<" attributes"<<endl;
    Element->GetScalarAttribute("Number of items", NumItems);
    cout<<NumItems<<" items"<<endl;

    // (2) output attributes to screen
    vtkXMLUtilities::CollateAttributes(Element,cout);
    cout<<endl;

    // (3) try to output the whole element to screen
    vtkXMLUtilities::FlattenElement(Element,cout);
    cout<<endl;

    // (4) try to write the  element to file
    vtkXMLUtilities::WriteElementToFile(Element,"element.xml");

    Element->Delete();
    return (0);
}

(1) and (2) work OK, but (3) outputs a single "<" without any other text

and (3) does not create any file.

any hint?
Thanks,
Sebastien





More information about the vtkusers mailing list