Click here to Skip to main content
15,886,026 members
Everything / XmlReader

XmlReader

XmlReader

Great Reads

by Dirk Bahle
Tips & Tricks on De/Serializing object graphs with XML
by Paul Schwartzberg
Formatting XML in a string for visual presentation.
by ASP.NET Community
XML namepace has XmlWriter class to write to XML file. Code in C#:using System.XML; //Add this namespace to use XmlWriter and XmlReader
by John Orendt
Prepares play list elements for burning to CD or DVD or loading onto a MP3 player.

Latest Articles

by Dirk Bahle
Tips & Tricks on De/Serializing object graphs with XML
by Altaf Ansari
Converting XML Data into DataTable and Exporting DataTable into Excel File
by Shuqian Ying
Client side data provider for data importing to a relational data service build for StackExchange data dump.
by ASP.NET Community
XML namepace has XmlWriter class to write to XML file. Code in C#:using System.XML; //Add this namespace to use XmlWriter and XmlReader

All Articles

Sort by Score

XmlReader 

22 Dec 2017 by Dirk Bahle
Tips & Tricks on De/Serializing object graphs with XML
10 Apr 2015 by Mario Z
This line doesn't make sense:string send = Encoding.GetEncoding("utf-8").GetString(Encoding.GetEncoding("utf-8").GetBytes(send));You see in .NET String is a collection of Unicode characters (or in better words a collection of Unicode code points) that represent a text which is encoded by...
10 Apr 2015 by Sergey Alexandrovich Kryukov
In addition to Solution 1:The content of XML should also be consistent with the actually applied encoding. With UTF-8, this is how your prolog should look:There is one delicate thing here: the BOM. First, read about...
5 Nov 2012 by MT_
Try using XmlDocument.It goes something like thisXmlDocument xDoc = new XmlDocument();xDoc.Load("YourFile.Xml");string sizeValue = xDoc.DocumentElement.SelectSingleNode("Size").InnerText;string nameValue = xDoc.DocumentElement.SelectSingleNode("Name").InnerText;string...
18 Oct 2013 by Sergey Alexandrovich Kryukov
Indeed, this is the invalid XML due to one problem: a character set. Typically, this is what you do to correct it:Add the following XML prolog before your text:Save your file in UTF-8. You can always do it programmatically.It will work, I...
13 Jun 2011 by Sergey Alexandrovich Kryukov
Here are the options to consider:Use System.Xml.XmlDocument class. It implements DOM interface; this way is the easiest and good enough if the size if the document is not too big.See http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx[^].Use the class...
1 Feb 2012 by avishekrc
Hi,I have the following xmldocument named as memberDoc: - A 000000001 HIS TMH ...
27 Mar 2012 by enhzflep
Well of course not!It does say xmlReaderForFile after all, doesn't it?Why aren't you just using xmlReaderForMemory[^]
9 Oct 2012 by fjdiewornncalwe
How hard did you look? It took me less than 30 seconds to find these:TinyXML[^]Simple C++ XML Parser[^]Expat[^]These are all on the first page of results: C++ XML Parser[^]
15 Nov 2012 by Sergey Alexandrovich Kryukov
Convert?! What's wrong with System.Xml.XmlReader.ReadElementContentAsInt or System.Xml.XmlReader.ReadContentAsInt? Anyway, if you need to "convert" (right term would be "parse"), you can always use int.Parse or...
19 Jan 2017 by johannesnestler
Nothing yet to help you....1. Learn coding basics for the given language/environment2. Learn the technology for your for your specific problem: like, Services, TCP, XML-Parsing and creation...3. Write code to solve your problem4. If you get stuck - come here again (or ohter place to...
5 Oct 2011 by Nicholas Butler
You have tagged this question with XmlReader, which is probably what you want to use to read your XML.XML serialization is a way of persisting objects and retrieving them later. It is not for reading arbitrary XML files.
12 Oct 2011 by Dave Kerr
Not a problem:xsi:schemaLocation="http://MYNAMESPACE ../../folder/relative/schema.xsd"But remeber: http://MYNAMESPACE must be replaced with the targetNamespace URI of your schema.
14 Oct 2011 by Reiss
This should help you on your way targetNamespace="http://tempuri.org/Alpha.xsd" elementFormDefault="qualified" xmlns="http://tempuri.org/Alpha.xsd" xmlns:mstns="http://tempuri.org/Alpha.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema"> ...
29 Dec 2011 by Member 4560027
You can use Xml.Linq for your query.using using System.Xml.Linq;//...//...//...private void QueryFromXml(string xmlFilePath){XDocument xmlDoc = XDocument.Load(xmlFilePath);var myNode= (from p in xmlDoc.Descendants("user") select...
29 Dec 2011 by NandaKumer
check this bloghttp://msdn.microsoft.com/en-us/library/bb397906.aspx[^]--NDK
1 Jan 2012 by Rajesh Anuhya
Try to read line this, this may solve your problem DataSet ds = new DataSet();ds.ReadXml("c:\\test.xml", XmlReadMode.IgnoreSchema);
30 Jan 2012 by gihanlasita
Hii have a xml data like this 1 100 100.00 1 ...
1 Feb 2012 by CPallini
What's wrong withstring retvalue = memberDoc.SelectSingleNode("ROOT/tblmembers/additionalinfo/patientadditionalinfo[@id='1']/race").InnerText;?
22 Jul 2012 by Christian Graus
You should use LINQ to read XML where-ever possible. If you have an actual question, ask it, it's not clear at all what this code does ( not much ) or what you want from us.
1 Aug 2012 by Sergey Alexandrovich Kryukov
loger21 asked a follow-up question:My question is, how to load XLIFF files using C#? [Punctuation/grammar fixed — SA]The XLIFF file is supposed to be a well-formed XML. If you follow the first approach I explain in my Solution 2, you can write a XLIFF parser based on one of available .NET...
9 Oct 2012 by lewax00
Since you're using .Net, I suggest reading How to: Parse XML with XmlReader[^].
17 Oct 2012 by Jochen Arndt
The version and encoding parameters must be quoted:char *xmldata = "...";
20 Jan 2013 by Deenuji
i want to create XML document search engine....if i give some keyword means that engine want to show some of results documents...thn i want to open that XML document in XML format in another window...
24 Jan 2013 by Sandesh M Patil
Refer below linkhttp://forums.asp.net/p/1877513/5280665.aspx/1?Re+how+to+search+content+words+from+multiple+existing+xml+documents+[^]
24 Mar 2013 by Sergey Alexandrovich Kryukov
Well, look at the XML standard. The character with the code point 0 is not considered as a valid character in XML.As you did not show how you obtained the XML file and did not show any XML sample, that's all. Everything else in your question is irrelevant: the parsing code may be correct,...
13 May 2013 by sixthplanet
Refer this link to manipulate with xml data'sManipulate XML data with XPath and XmlDocument (C#)[^]
13 May 2013 by Mohammed Hameed
I think it is better to use XmlReader for reading xml files.Refer this link: http://stackoverflow.com/questions/5827668/how-to-read-xml-file-using-xml-reader[^]
21 Feb 2013 by TRK3
All the times are the same order of magnitude and relatively close to each other, so they aren't actually encrypted. Most likely they are just the total number of some units of time since some origin date.It's either seconds, or milliseconds, since some date.1359279658478...
14 Oct 2013 by Member 10230387
I have a problem when read xlsx to xml code:{ DataSet ds = new DataSet(); string myXMLfile = @"E:\a.xlsx"; ds.ReadXml(myXMLfile);}message error:[ data at the root level is invalid. line 1 position 1.]
17 Dec 2013 by Sergey Alexandrovich Kryukov
Please see my short overview of the approaches to XML parsing offered by .NET FCL:Use System.Xml.XmlDocument class. It implements DOM interface; this way is the easiest and good enough if the size if the document is not too big.See...
30 Jan 2014 by TnTinMn
Quote:Any ideas that are simpler to read the required values from the XML other than XMLReader would be greatly appreciatedPersonally, I find this approach easier.Private Sub TestXML() Dim sbSource As New System.Text.StringBuilder(200) With sbSource .AppendLine("
5 Feb 2014 by Vedat Ozan Oner
here:using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Xml;using System.Xml.Linq;namespace Test_XmlChange{ class Program { static void Main(string[] args) { ...
5 Feb 2014 by RhishikeshLathe
Refer following code :-string szFilePath = @"D:\ABC.xml";//ur file path XmlDocument objDOM = new XmlDocument(); objDOM.Load(szFilePath);//you can specify file name here int iIndex = 0; foreach (XmlNode objXNode in...
17 Mar 2014 by Vedat Ozan Oner
you can make your array 'a' sorted. List a = g.ToList().Select(i=>int.Parse(i)).OrderBy(i=>i);List missings=new List();int idx=0; // a indexfor(int i=0; i
20 Mar 2014 by ZurdoDev
I would use the XDocument or you could also use the XmlDocument. The XDocument is newer and supports Linq.http://msdn.microsoft.com/en-us/library/system.xml.linq.xdocument_methods(v=vs.110).aspx[^]You can use Elements() or Descendants() etc.
6 Apr 2014 by CHill60
Debug your code and put a breakpoint on the line XElement el = XNode.ReadFrom(reader) as XElement;When the code reaches that point for the first time, hover over the variable reader and you will notice that it has the name "Text" - what you would expect!Now F10 over the breakpoint and hover...
10 Apr 2014 by cazanova007
Based on this article some code : EMGU Multiple Face Recognition using PCA and Parallel Optimisation[^]// The trainingfaces file john 25 Student in MS...
10 Apr 2014 by gggustafson
In the following fragment, load_training_data does what you want using XPath[^].using System;using System.Collections.Generic;using System.Windows.Forms;using System.Xml;namespace LoadingFace { public partial class LoadingFace : Form { ...
24 May 2014 by Maciej Los
Sorry, but no one wants to analyze your XML file.Please read my answer to your previous question: Error while converting xml to excel in vb.net[^]As i wrote there, you can open XML via Excel application. Follow the links i provided. There you'll find many usefull information about opening...
13 Aug 2014 by Yogesh Kumar Tyagi
view this link for mvc tree view How to Create TreeView in MVC3[^]i think it will help you.Build a custom MVC Tree Control by using jsTree[^]
21 Oct 2014 by Sergey Alexandrovich Kryukov
This is not a valid file name. You cannot use "~". If you remove '~', it will mean the file path starting from the root directory on the current volume (bad idea, anyway). Moreover, there are no situations when using hard-coded file paths can be useful. Path names should always be calculated...
21 Oct 2014 by BillWoodruff
Once you get rid of the "~" and get the file path right, check whether the File exists before you try to read it, and do something appropriate if it does not exist:string YourFilePath = @"C:/SomeDirectory/SomeFile.xml";if(! File.Exists(YourFilePath)){ throw new...
8 Apr 2015 by OriginalGriff
Try:using (SqlConnection con = new SqlConnection(strConnect)) { con.Open(); using (SqlCommand cmd = new SqlCommand("SELECT myPDFData FROM myTable", con)) { using (SqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) ...
14 May 2015 by Maciej Los
The error message is quite understandable. Please, refer xml documentation: Extensible Markup Language (XML) 1.1 - documents[^]:Quote:[Definition: There is exactly one element, called the root, or document element, no part of which appears in the content of any other element.] For all other...
17 Sep 2015 by Sergey Alexandrovich Kryukov
.NET FCL offers different ways to parse XML. This is my short overview of them:Use System.Xml.XmlDocument class. It implements DOM interface; this way is the easiest and good enough if the size if the document is not too big.See...
16 Apr 2016 by Richard MacCutchan
See https://docs.oracle.com/javase/tutorial/jaxp/xslt/writingDom.html[^].
27 Feb 2018 by Graeme_Grant
Firstly, you have an error in the XML data sample on line# 443. I would map classes to the XML data and convert. But it you want to manually read the xml data, then you could do something like this: var doc = XDocument.Parse(rawXml); var products = doc.Descendants() ...
29 Mar 2022 by Richard Deeming
Seems simple enough using LINQ to XML[^]: // Values to find: string pin0 = " value0 ", pin1 = null, pin2 = " value2 ", pin3 = null; XDocument document = XDocument.Load("load.xml"); var select = doc.Descendants("Select").Select(s => new { ...
21 May 2011 by Ravi Sharma 2
hi Everyone,I make one webservice "myweb" and add reference to this webservice to C# web application. project. I call the web service method validate("5","62") in to web application. ReconServiceService objReconServiceService = new ReconServiceService(); String s =...
13 Jun 2011 by javad_r_85
Hi for Exampel- - آذرشهر اسکو اهر بستان‌آباد بناب تبریز
13 Jun 2011 by Kim Togo
You can use XPath[^] querys and find info.Select Nodes Using XPath[^] or Manipulate XML data with XPath and XmlDocument (C#)[^]
12 Jul 2011 by Paul Schwartzberg
Formatting XML in a string for visual presentation.
24 Jul 2011 by April2004
Finally, i got suitable solution by myself after testing several patterns ..The following code is my solution.MSXML2::IXMLDOMNodeListPtr pNodeList=pDoc->getElementsByTagName("value_content");int nList = pNodeList->length;for( int n = 0; n get_item(n, &pName); ...
8 Sep 2011 by Member 8214635
hi guys,how can i read a specific node from 4 node in xml and store its element in dataset or arraylist.thanks
8 Sep 2011 by KenBonny
You might want to look into XLINQ. Start here:Reading XML documents using LINQ[^].NET Language-Integrated Query for XML Data[^]These are not LINQ to XML (or XLINQ) specific, but give you a lot of examples using LINQ in general:101 LINQ Samples[^]
8 Sep 2011 by CPallini
I would start reading the documentation: "Using the XmlReader Class"[^].
5 Oct 2011 by Jason K Smith
I have XML meta data from a digital video recorder that a client has asked me to generate a schema for. The XML I have is as follows: ...
6 Oct 2011 by Ganesan Senthilvel
xsd tool is used to generate XML schema using run time component. You can use it. Ref at: http://msdn.microsoft.com/en-us/library/x6c1kb0s.aspx[^]
6 Oct 2011 by Mastersev
Hey Guys,Assigning the Linq query result to the DataGrid datasource it takes a lot of time (40 seconds) and I only have 8000 entries (rows)in the XML file. I know that this can be fixed by looping through the Linq result elements and adding them to the grid view one by one but is there any...
6 Oct 2011 by Mastersev
Setting t he AutoSizeColumnsMode = False; & AutoSizeRowsMode = False; solved it. Now it loads 10000 records in 2 seconds!
12 Oct 2011 by Patrick Skelton
Hi,I have an XML document which references a single XSD schema file which are both in the same directory. When referencing the schema in the XML file, is it possible to use a relative URL? If not, is there a way round the problem of having to maintain different versions of the XML file on...
12 Oct 2011 by Patrick Skelton
Got it now, thanks. Your reply puts my mind at ease because I had read a lot of (sometimes) contradictory information on schemas, and at least one website I visited said something about relative URLs not being allowed and most only gave explicit full URLs.I think my local working copy was...
13 Oct 2011 by Patrick Skelton
Well, it's official: I'm thick. I have been programming years, but have never had to define an XML schema before and it is driving me up the wall. Despite looking at tens of examples, I just can't get the syntax right for defining an mandatory attribute on an element with the restriction that...
14 Oct 2011 by Patrick Skelton
That's brilliant! Thank you.- Patrick
27 Oct 2011 by Mostafa Elsadany
hi everyone i created this method in me web service [WebMethod]public XmlReader fromxml() { XmlReader x; cmd.Connection = conn; cmd.CommandText = "selete* from test_emp"; conn.Open(); x =...
27 Oct 2011 by Mark Salsbery
And when you fix the NotFound error...You don't pass XmlReader objects. You'd pass Xml data and use Silverlight's XmlReader class to parse it....
27 Oct 2011 by Mostafa Elsadany
hi every one how i can retrieve to silverlight from web service returned XmlDocumentor how i can retrieve xml data form web service to silverlight thanks for any help
27 Oct 2011 by Abhinav S
These links should help you out - http://forums.silverlight.net/t/11702.aspx[^]http://blogs.silverlight.net/blogs/msnow/archive/2009/02/10/silverlight-tip-of-the-day-93-reading-xml-with-silverlight.aspx[^]
28 Oct 2011 by Mark Salsbery
Accessing Web Services in Silverlight[^]
2 Nov 2011 by shelby67
Let's breakdown the search process, then create the search function in C#1.) What are we looking for?2.) Where in the file do we THINK it might be? (top, bottom, left, right, upside down?)...etc3.) search that location4.) IF your desired substring isn't found then search the whole file,...
10 Nov 2011 by Member 4417892
Hi there,I am using a library for communication to a PLC.Today it out of nowhere "crashed" with the following error:There is an eror in XML-docoment (0, 0). Rootelement is missingI know that its the rootelement that is missing in a XML-file, but the problem is its a library with...
10 Nov 2011 by thatraja
Here a fix linkThere is an error in XML document (0, 0) during Deserialization[^]
11 Nov 2011 by Member 4417892
Had to use Reflector to decompile the dll file and find the directory to the .XML file and then change it.
18 Nov 2011 by OriginalGriff
Use XMLReader: MSDN has instructions: How to read XML from a file by using Visual C#[^]
29 Dec 2011 by kurtiniadiss
Hi all,I am new in XML and have some problems to execute queries on xml db. I am using exist native xml db. Can you write sample insert, update,delete queries and how to execute them.this is my sample xml file: Frederick ...
10 Jun 2018 by Sumit Kumar Singh India
Hello Guys,I have a XML Document which contains multiple tables. i unable to read it in a dataset(i am able to read xml document which contains single table)Exception Error Message:Cannot add constraint to DataTable 'srgbClr' which is a child table in two nested relations....
1 Jan 2012 by Uday P.Singh
Refer this article:Introduction to DataSets and working with XML files[^]hope it helps :)
1 Feb 2012 by Amir Mahfoozi
I copied and pasted what you have provided into a file named "test.xml" (of course removed that extra dash from second line)and tested this code : XmlDocument rawXMLData = new XmlDocument(); StreamReader reader = new StreamReader(@"d:\test.xml"); ...
6 Feb 2012 by BrahmDutt
I have different XML files in my intranet, i want to create a HTML page where i can show all my XML feed. what is a best way to create & load different XML feed on a single page ..please help me on this
6 Feb 2012 by Christian Graus
The best way is to use XSLT to convert your data in to html, so that you point each file at the stylesheet and get out the html you want.
23 Feb 2012 by comred
Hi All.I have made a web service in Asp.net which returning some data in form of xmlElement.Now I have php client, but I don't know how to get those records. Because its not an xml file. So I am not able to use predefine functions available in php.I am very much new to php, Its just...
28 Feb 2012 by comred
$var = $s->call('GetDataFromServices', array('parameters' => $param['date'],$param['type'])); function test_print($item, $key) { echo "$key holds $item\n"; } array_walk_recursive($var, 'test_print');
7 Mar 2012 by BigChaw
Hello everybody,I am pretty new to datagridviews/datasets/etc. I do know xml however. My problem is this, I am currently trying to get my datagridview to display all the data inside an xml file. After about 8 hours of looking throughout google, I am more confused then ever. The common solution...
7 Mar 2012 by BigChaw
I did stumble on that one already, but its in C# - so I have to transfer it over to c++ in an effort to get rid of all the compile errors and make it actually work.
27 Mar 2012 by rockpune
i would like to read attribute display in listbox it is displaying but problem is it is displaying all attributes when i enter "PLAYER_SETTINGS" in textbox,but i want to display only that attributes whatever i give in textbox,it means when i give ERROR in textbox i have to display only ERROR...
2 Apr 2012 by cpquest
Hi all,i have some doubts in creating xml from a class that i have. I need to grenerate a xml file in my local filesystem the Nodes and Data of a xml should be Generated once from the first time. What ever changed made in the data should be saved in the genereated XML in my local file system...
2 Jul 2012 by E.F. Nijboer
My guess would be that you need to recreate the file instead of open or create. You probably write over the existing data in the file. If the previous content of the xml file was like this (both numbers are 3 characters long):
17 Aug 2012 by Member 9342142
I am very new to C# programming. I have a .csv with 7 Columns. The columns headings output to xml but the row data does not. The data is tab delimited. Where is my code broken to not output the row data? I am using monodevelop on an Ubuntu 12.04 system. Thank you so...
17 Aug 2012 by Zoltán Zörgő
Have you tried to debug it? This is a quite simple code, debugging it might reveal, what is wrong.You have to set table.TableName = "SomeTableName";and use this:while (!reader.EndOfStream) { table.Rows.Add(reader.ReadLine().Split('\t')); }Final code:using...
21 Aug 2012 by Mahesh Kumar Badgujar
Hi,I have a .gml file and 1 .xsd . now how to validate this gml with xsd.i am beginner. please provide detailed explaination.Thanks & Regards,Mahesh
11 Sep 2012 by Sergey Alexandrovich Kryukov
With such a simple XML file, you can use JavaScript window.DOMParser or Microsoft.XMLDOM (actually, both of them, for browser compatibility). Please see:http://www.w3schools.com/xml/xml_parser.asp[^].Actually, the major problem is to bring the many XML APIs available in nearly all parsers...
16 Sep 2012 by Member 8555298
I am just starting with XMLTextReader so apologies if the answer is obvious.I am trying to extract attributes from an XML file, which appears to have the same element name wrapped within itself. This extract shows the problem:
20 Sep 2012 by mody_sosa
dear Allkindly i have a qustion i have a code to read an xml file to make new ticker tape and i want to check element if more than zero, change the color in tickerplease help me if you canand the code is
20 Sep 2012 by Ashraff Ali Wahab
I have hardcoded the colors you can use class.var ajxObj;if (window.XMLHttpRequest) {ajxObj = new XMLHttpRequest();} else {ajxObj = new ActiveXObject('Microsoft.XMLHTTP');}ajxObj.open('GET', 'OutputXML.xml', false);ajxObj.send();var...
22 Sep 2012 by muntaserz
hello i developed news site and am trying to read rss from another site i used this code to read private void GetRSS() { try { WebRequest rssReq =...
22 Sep 2012 by Christiaan Rakowski
Security issues can come from too many things to be able to give you an answer based on this, could you maybe provide the inner exception and/or stacktrace(s).Even tho, I will give you some common issues I've encountered before:Most security exceptions are related to cross origin...
7 Oct 2012 by Mayur2258
Hi All,I am working on XML files. I have created small XML tool which returns number of specific tag repeated in all files.This code runs properly to find the numbers of tag present in files within specific folder mean there should not be any other folder in XML files containing folder....
9 Oct 2012 by eugene.shikhov
http://xerces.apache.org/xerces-c/[^]