You need to sign in to do that
Don't have an account?
How to read String type Xml Format through Xml Stream Reader..??
I am trying to read the Xml Format in salesforce by doing this
bodyxml ='<?xml version="1.0"?><Data><Result>True</Result><Password>hello</Password></Data>';
But what i am unable to do is how to get it iterated , in XMLStreamReader Class , I have been through the example below but it iterates on the class and i m not able to understand how is it doing with the Class "Book" as shown below ...
What need is to learn how Iterate through the string as defined above ..... In an XMLStreamReader Class so i can see step by step working in debug . The Code given as help by salesforce is given below . Pls have look ......
I hope i have desbribed it right ....
public class XmlStreamReaderDemo { // Create a class Book for processing public class Book { String name; String author; } public Book[] parseBooks(XmlStreamReader reader) { Book[] books = new Book[0]; while(reader.hasNext()) { // Start at the beginning of the book and make sure that it is a book if (reader.getEventType() == XmlTag.START_ELEMENT) { if ('Book' == reader.getLocalName()) { // Pass the book to the parseBook method (below) Book book = parseBook(reader); books.add(book); } } reader.next(); } return books; } // Parse through the XML, determine the author and the characters Book parseBook(XmlStreamReader reader) { Book book = new Book(); book.author = reader.getAttributeValue(null, 'author'); while(reader.hasNext()) { if (reader.getEventType() == XmlTag.END_ELEMENT) { break; } else if (reader.getEventType() == XmlTag.CHARACTERS) { book.name = reader.getText(); } reader.next(); } return book; } }
There is one more problem with this code that it gets saved for the first time but after some changes of like writing a simple debug it starts giving an error ...
Error: Save error: Method does not exist or incorrect signature: [XMLStreamReader].getLocalName()
Document Dom is one method i want to understand XMLstreamReader
Thank you
Try the below code;
This would assing the Value 'Hello' which is under <Password> tag to String variable s.
I did the this but enable to save the class
Gives me the below error
Error: Compile Error: Method does not exist or incorrect signature: [XMLStreamReader].getText() at line 12 column 23
Also tried this ...
Gives me below error
Error: Compile Error: Constructor not defined: [XMLStreamReader].<Constructor>(String) at line 6 column 29
Try below code :-
content type as xml format using future(callout=true) in salesforce using trigger in salesforce.
given the request as string xml format and i want to get the response in xml format.can you please give me the example of above scenario