pablo007 Posted September 28, 2015 Posted September 28, 2015 Hi all I am just getting started with C# (having no real coding experience ) I wish to create a small exe that will read an xml file pulled from sims.net which includes their full name and photo (the xml pulls it out as code so it will need to be converted into an image) the xml is the following Mrs L woks Lisa lots of code here that will hopefully be converted to an image The code I have thus far is; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace reading_xml { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void ReadXMLBUtton_Click(object sender, EventArgs e) { string filePath = "C:\\authors.xml"; AuthorsDataSet.ReadXml(filePath); dataGridView1.DataSource = AuthorsDataSet; dataGridView1.DataMember = "record"; } private void Showschemabutton_Click(object sender, EventArgs e) { System.IO.StringWriter swXML = new System.IO.StringWriter(); AuthorsDataSet.WriteXmlSchema(swXML); textBox1.Text = swXML.ToString(); } private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { } private void button1_Click(object sender, EventArgs e) { private void ReadXMLBUtton_Click(object sender, EventArgs e) { string filePath = "C:\\authors.xml"; AuthorsDataSet.ReadXml(filePath); dataGridView1.DataSource = AuthorsDataSet; dataGridView1.DataMember = "record"; } private void Showschemabutton_Click(object sender, EventArgs e) { System.IO.StringWriter swXML = new System.IO.StringWriter(); AuthorsDataSet.WriteXmlSchema(swXML); textBox1.Text = swXML.ToString(); } private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { } } } I really need help here as its not converting the image although is readingthe text. thank as always.
Meldrew Posted September 28, 2015 Posted September 28, 2015 I tend to avoid c# 's inbuilt xml facilities as I find them over complicated, however are you able to see the photo 'information'? It is base 64 encoded, so if you can see the encoded string, you can use a base 64 decoder utility to spit out an image. HTH, Meldrew
pablo007 Posted September 28, 2015 Author Posted September 28, 2015 if theres an easier language I will glady try it ? I can see the photo information it is encoded so how do I go about using the base 64 decoder utlity ? thank sso far mate
AXE Posted September 28, 2015 Posted September 28, 2015 Maybe something like... System.Drawing.ImageConverter converter = new System.Drawing.ImageConverter(); byte[] bytes_image = Convert.FromBase64String(xml_image_string); object object_image = converter.ConvertFrom(bytes_image);
LosOjos Posted September 28, 2015 Posted September 28, 2015 (edited) I made a tool to do this a while ago: https://dl.dropboxusercontent.com/u/4779199/SIMSImageGrabber%20Source.zip The source is included in that file too if you want to take a look - it's very messy but you can see how it works EDIT: The SIMS reports you pass to this should contains: Students: Surname & Forename, Admission number, External Id, Photo, Person_id, UPN Staff: ID, Photo, Title, Preferred Surname, Preferred Forename, Initials, Teacher You can of course change the columns you include in your own program, these are the ones mine looks for. Edited September 28, 2015 by LosOjos
pablo007 Posted September 28, 2015 Author Posted September 28, 2015 Thank you will take a look and let you know how I get on thanks again.
Meldrew Posted September 28, 2015 Posted September 28, 2015 if theres an easier language I will glady try it ? I like c#, but just its XML routines I tend to avoid. I tend to avoid XML now too - json is much nicer!
pablo007 Posted September 28, 2015 Author Posted September 28, 2015 hi Its not quite what I seek essentially I am trying to write a staff id card version of a program (bonsaid)that someone (he no longer develops the program)wrote for pupils. the program is perfect for my use but I need to change some parameters in the program that cannot be changed in sims.net (I have tried..)
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now