Display a image in picturebox
-
i just want to load one image to the picturebox, who's path is stored in xml file. please tell me how to do this. GIve examples.
kpuneeth7 wrote:
GIve examples
Without knowing a little about the structure of your XML file and what technology you're using, that would be difficult to do... But it's simply a case of reading the XML file with an XML parser (think XmlReader in .NET), and finding the node containing the image file's path. The rest of it (displaying the image in the picture box) is nothing to do with XML.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p CodeProject MVP for 2010 - who'd'a thunk it!
-
kpuneeth7 wrote:
GIve examples
Without knowing a little about the structure of your XML file and what technology you're using, that would be difficult to do... But it's simply a case of reading the XML file with an XML parser (think XmlReader in .NET), and finding the node containing the image file's path. The rest of it (displaying the image in the picture box) is nothing to do with XML.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p CodeProject MVP for 2010 - who'd'a thunk it!
-
I am using a simple xml file..... C:\Documents and Settings\Imran\Desktop\Picture\apple.jpg And i am using visual studio 2008 C# language. .net framework
modified on Wednesday, February 24, 2010 3:20 AM
Here's a short C# program that will read the bit of XML you want and write it to the console.
using System.Xml.XPath;
using System.IO;namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
// The XML file is specified as the first command line argument
// imagePath will contain the image path contained in the XML file
string imagePath = new XPathDocument(new StreamReader(args[0])).CreateNavigator().SelectSingleNode("/image/img").Value;
System.Console.WriteLine(imagePath);
}
}
}I've used XPath to navigate to the required element in the XML file (that's the
.SelectSingleNode("/image/img")
bit) and read the text there (the.Value
bit). Simples.Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p CodeProject MVP for 2010 - who'd'a thunk it!
-
Here's a short C# program that will read the bit of XML you want and write it to the console.
using System.Xml.XPath;
using System.IO;namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
// The XML file is specified as the first command line argument
// imagePath will contain the image path contained in the XML file
string imagePath = new XPathDocument(new StreamReader(args[0])).CreateNavigator().SelectSingleNode("/image/img").Value;
System.Console.WriteLine(imagePath);
}
}
}I've used XPath to navigate to the required element in the XML file (that's the
.SelectSingleNode("/image/img")
bit) and read the text there (the.Value
bit). Simples.Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p CodeProject MVP for 2010 - who'd'a thunk it!
-
You need to give a command line argument that specifies the XML file...the code comments DO say that....
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p CodeProject MVP for 2010 - who'd'a thunk it!
-
You need to give a command line argument that specifies the XML file...the code comments DO say that....
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p CodeProject MVP for 2010 - who'd'a thunk it!