Convert string to xml file c#




















I'm not sure what I read when I posted that I coulda swore it took a filename. Now I feel sheepish. Sir I use this but i got same error "Data at the root level is invalid. Line 1, position 1. I'm not sure what you mean by this. There was an issue with the quotes I typed that too quickly without thinking but I'm not sure what the problem is with the newline. LoadXml s ;. Ask a question. Quick access.

Search related threads. Remove From My Forums. Answered by:. Archived Forums. Visual C. Sign in to vote. I share my whole code.. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Podcast Making Agile work for data science. Stack Gives Back Featured on Meta. New post summary designs on greatest hits now, everywhere else eventually. Linked 1. Related Hot Network Questions. Question feed. Stack Overflow works best with JavaScript enabled.

If you want create xml file and then assign it to string variable use Linq 2 Xml it's the fastest way. Sachin:No,I want to generate an XML file and save it into a string variable,I must not save any files or use any files from the hard disk,I appreciate your help — Pedram. Add a comment. Active Oldest Votes. Community Bot 1 1 1 silver badge. Sachin Sachin Be aware that File. ReadAllText will lock the file. If you do not wish to lock the file you should use a FileStream with a StreamReader in a using statement.

Open, FileAccess. Read, FileShare. The same remark if you use XmlDocument. Load this will also lock the file. To avoid use the stream alternative. Append char. ToUpper node. Name[0] ; sb. Append node. Substring 1 ; sb. Append ' ' ; sb. AppendLine node.



0コメント

  • 1000 / 1000