Convert string to document talend
Get via App Store Read this post in our app!
Talend tRESTClient requires Document data type in schema
I'm using the tRESTClient to call a REST service to post a JSON string (with records). The tRESTClient component does not allow me to use a custom schema that matches my string. it says:
the method getDocument() is undefined for the type String
It seems is trying to execute the getDocument against the schema but the input schema is a STRING not a DOCUMENT data type.
If I use a tMAP to try to convert my json String to a Document, I get this error:
Type Mismatch: cannot convert from String to Document
how does one convert a string to a document? this is a json string such as this:
You store your string in json file and then read data from that json file and use tXMLMap Component to provide input to tRESTClient tFileInputJson -> tXmlMap -> tRestClien i hope it will help :)
Convert string to document talend
Get via App Store Read this post in our app!
Talend: from XML file to String using tXMLMap
I have a job with a tESBConsumer that has this method: "call(string):string".
The input string must be an entire xml file. So, I drag a tFileInputXML linked to a tXMLMap linked to tESBConsumer linked to a tLogRow.
It doesn't work! I don't know if this is correctly way or there is a easier way (like tMap) to do what I want.
tFileInputRaw is the component which allows you to read the raw file as a string or as bytes array or stream the file. This you can use to read your xml file and return entire file content as string
Convert string to document talend
Get via App Store Read this post in our app!
How to convert String to DOM Document object in java?
I have a case like getting an XML and convert the XML elements to document object and getting the element values and attributes which i have been created already
Here is the piece of code i have tried to convert the string to DOM document object
But this case is valid for only elements without attributes what can we do if the
we are using Double quotes for the attribute values"value". The compiler is showing error
Suggest me if there any xml encoder and decoder is there to handle this scenarios ??
Either escape the double quotes with \
or use single quotes instead
this works well for me even though the XML structure is complex.
And please make sure your xmlString is valid for XML, notice the escape character should be added "\" at the front.
The main problem might not come from the attributes.
Convert string to document talend
I tried to convert Document object to String object, but it is unsuccessful. Anyone knows
public class ParserTest
public static void main(String[] args) throws ParserConfigurationException, SAXException
String xmlFile = "mydoc.xml";
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse(new File(xmlFile));
Element root = doc.getDocumentElement();
String s = root.toString();
Threaded Messages (3)
- Convert Document object to String object by Ravi Srirangam on May 21 2004 02:19 EDT
- Thanks Ravi Sri by Nagesh Babu S on August 30 2004 13:22 EDT
- Convert Document object to String object by vijay m on April 08 2011 08:33 EDT
Convert Document object to String object [ Go to top ]
- Posted by:Ravi Srirangam
- Posted on: May 21 2004 02:19 EDT
- in response to Matt Louden
Here is the method that converts the Document to String equivalent
public String getStringFromDocument(Document doc)
DOMSource domSource = new DOMSource(doc);
StringWriter writer = new StringWriter();
StreamResult result = new StreamResult(writer);
TransformerFactory tf = TransformerFactory.newInstance();
Transformer transformer = tf.newTransformer();
Thanks Ravi Sri [ Go to top ]
- Posted by:Nagesh Babu S
- Posted on: August 30 2004 13:22 EDT
- in response to Ravi Srirangam
Convert Document object to String object [ Go to top ]
- Posted by:vijay m
- Posted on: April 08 2011 08:33 EDT
- in response to Matt Louden
It is good logic whatever you are using. made some chages to your code .now it is working fine. find the working code.
public class Sample <
public static void main(String[] args)
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse(new File(xmlFile));
Element root = doc.getDocumentElement();
String s = root.toString();
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations technology projects - with its network of technology-specific websites, events and online magazines.