Use wtk.js vtkXMLPolyDataReader class to load data from XML string
See original GitHub issueHello,
I try to use the vtkXMLPolyDataReader in a javascript, but i don’t want to use a file, i receive a XML in a string :
<?xml version="1.0"?><VTKFile type="PolyData" version="0.1" byte_order="LittleEndian" header_type="UInt32" compressor="vtkZLibDataCompressor"><PolyData><Piece NumberOfPoints="38496" NumberOfVerts="0" NumberOfLines="0" NumberOfStrips="0" NumberOfPolys="53488">...
How I can load this data in the vtkXMLPolyDataReader . I try vtkXMLPolyDataReader.loadData(xml_string); but it does not seem to work. Many thanks for your help.
Patrick
Issue Analytics
- State:
- Created 5 years ago
- Comments:6
Top Results From Across the Web
XMLPolyDataReader | vtk.js - Kitware, Inc.
vtkXMLPolyDataReader is a source object that parses a VTK XML input file. ... import vtkPolyData from 'vtk.js/Sources/Common/DataModel/PolyData';
Read more >vtkXMLPolyDataReader Class Reference - VTK
vtkXMLPolyDataReader reads the VTK XML PolyData file format. One polygonal data file can be read to produce one output. Streaming is supported. The...
Read more >Loading a xml to a class with Javascript - Stack Overflow
In Safari a URL with the document is created and called through an XMLHTTPRequest. Like all XMLHttpRequests, you use the standard responseXml ......
Read more >Using JAXB And StaxEventItemReader To Read XML Data
Here's the code for this new EmployeeContactXML class that will be used to map the XML file. Getters and setters have been removed...
Read more >How to Convert XML to Java Object - JAXB Unmarshalling
Java Architecture for XML Binding (JAXB) is a Java standard that defines how Java objects are converted from and to XML. It uses...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Hi @daker and thanks for pointing me in the right direction.
After some more research I figured as much from its name, but being rather new to JavaScript I needed some more time to understand it.
I tried to convert my string to an ArrayBuffer using
encodedString = TextEncoder().encode(XMLString)as explained here on SO and callingparseAsArrayBufferwithencodedString.buffer, but got yet another error now statingInvalid data type null expecting PolyDataAm I creating my ArrayBuffer correctly? (edit: Yes!)
Edit: I did create my
ArrayBuffercorrectly. The error was due to a call to theXMLPolyDataReader.loadData()function that should not have been there.For anyone struggling, here’s the lines of code to transform the XML string to a
vtkActorwith all its associated parts:@ZbindenJoel parseAsArrayBuffer needs an
ArrayBufferto work not a string