Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jun 02, 2012 01:53 AM by Decker Dong - MSFT
0 Points
1 Post
May 31, 2012 03:33 PM|LINK
Hello All,
I have problem with my code.Can some please help on this.I am pasting sample code below.
I want to serialize below class..
[Serializable()] public class VivaCreateUser : VivaEntityBase { private string _emailAddress, _username, _password; public VivaCreateUser(Guid realtorAgentID, string integrationUri, string apiKey, string actionName) : base(realtorAgentID, integrationUri, apiKey, actionName) { } public VivaCreateUser() { } public string Email { get { return _emailAddress; } set { _emailAddress = value; } } public string Username { get { return _username; } set { _username = value; } } public string Password { get { return _password; } set { _password = value; } } }-------I am using following way..actua;;y I wana trasfer xml to xslt.
public static string TransformXMLtoXsl(string xmlDoc, string xslDoc, Dictionary<string,object> xslArgs ) { StringBuilder sbOutput = new StringBuilder(); try { XsltArgumentList argList = new XsltArgumentList(); if(xslArgs!= null) { foreach (KeyValuePair<string, object> de in xslArgs) { argList.AddParam(de.Key, string.Empty, de.Value); } } //read xml string TextReader trEmail = new StringReader(xmlDoc); XmlTextReader xtrEmailXml = new XmlTextReader(trEmail); XslCompiledTransform xslTransform = new XslCompiledTransform(); if (xtrEmailXml.Read()) //Here I am facing the problem,it is throwing "Data at the root level is invalid. Line 1, position 1. { XPathDocument xmlPathDoc = new XPathDocument(xtrEmailXml); //read xsl TextReader trXsl = new StringReader(xslDoc); XmlTextReader xtrXslEmailTemplate = new XmlTextReader(trXsl); xslTransform.Load(xtrXslEmailTemplate); //Output stream TextWriter twOut = new StringWriter(sbOutput); xslTransform.Transform(xmlPathDoc, argList, twOut); } xslTransform = null; } catch (Exception error) { throw new ApplicationException(string.Format("Transformation Error : {0}", error.Message), error); } return sbOutput.ToString(); }
Can someone help me on this?
Contributor
6455 Points
1187 Posts
Jun 01, 2012 12:47 PM|LINK
The XML data in the variable xmlDoc is not valid. Save the string as an XML-file and try to open it up in your browser to find any errors.
All-Star
118619 Points
18779 Posts
Jun 02, 2012 01:53 AM|LINK
Pandu M R /Here I am facing the problem,it is throwing "Data at the root level is invalid. Line 1, position 1.
Have you got anything else in front of root? If yes,please remove it;even if it's a comment……
Reguards!
Pandu M R
0 Points
1 Post
Transformation Error : Data at the root level is invalid. Line 1, position 1.
May 31, 2012 03:33 PM|LINK
Hello All,
I have problem with my code.Can some please help on this.I am pasting sample code below.
I want to serialize below class..
Can someone help me on this?
mm10
Contributor
6455 Points
1187 Posts
Re: Transformation Error : Data at the root level is invalid. Line 1, position 1.
Jun 01, 2012 12:47 PM|LINK
The XML data in the variable xmlDoc is not valid. Save the string as an XML-file and try to open it up in your browser to find any errors.
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: Transformation Error : Data at the root level is invalid. Line 1, position 1.
Jun 02, 2012 01:53 AM|LINK
Have you got anything else in front of root? If yes,please remove it;even if it's a comment……
Reguards!