to read xml file
-
Hi all I posted this question yesterday also and no one replied me. I think no one is willing to help me or angry with me...... I want to read a particular node of xml file. For that i am using the code
XmlTextReader reader = new XmlTextReader ("tx1.xml"); while (reader.Read ()) { if(reader.IsStartElement ()) { if (reader.NodeType == XmlNodeType.Element && reader.Name == "jid") { str=reader.ReadString(); Lblmsg.Visible=true; Lblmsg.Text="journal ID <"+ reader.Name+ "> is : "+str; reader.Read(); break; } break; } }
but here the problem is it is trying to validate the xml file using the DTD. I dont want to validate it using dtd. Plz help to solve this. what i have to use here.:( Plz help me thank uWhy are you using an XmlReader? You could load the document into an
XmlDocument
object and then use XPath queries andSelectSingleNode
orSelectNodes
calls to get the node you are interested in.Scott.
—In just two days, tomorrow will be yesterday. [Forum Guidelines] [Articles] [Blog]
-
Why are you using an XmlReader? You could load the document into an
XmlDocument
object and then use XPath queries andSelectSingleNode
orSelectNodes
calls to get the node you are interested in.Scott.
—In just two days, tomorrow will be yesterday. [Forum Guidelines] [Articles] [Blog]
Scott is absolutely correct. XPath is fastest among all in parsing xml node.
Regards Chintan www.visharadsoft.com (Nothing is so purify as KNOWLEDGE)
-
Scott is absolutely correct. XPath is fastest among all in parsing xml node.
Regards Chintan www.visharadsoft.com (Nothing is so purify as KNOWLEDGE)
Chintan.Desai wrote:
Scott is absolutely correct. XPath is fastest among all in parsing xml node.
YES he is. But if the XML file is pretty huge, then this method may take some time. I think XMLDocument class loads the entire XML file to the memory when it initializes. Am I right ?
-
Why are you using an XmlReader? You could load the document into an
XmlDocument
object and then use XPath queries andSelectSingleNode
orSelectNodes
calls to get the node you are interested in.Scott.
—In just two days, tomorrow will be yesterday. [Forum Guidelines] [Articles] [Blog]
-
I want to read a huge xml file and the node that i want to read is about to the middle of the file. Then also XPath is of to use?
P_Elza wrote:
I want to read a huge xml file and the node that i want to read is about to the middle of the file. Then also XPath is of to use?
Why don't you write an application that compares performance difference for both the methods. I feel loading huge XML file to XMlDocument class will be slow compared to other.
-
Chintan.Desai wrote:
Scott is absolutely correct. XPath is fastest among all in parsing xml node.
YES he is. But if the XML file is pretty huge, then this method may take some time. I think XMLDocument class loads the entire XML file to the memory when it initializes. Am I right ?
Yes, you are correct. The
XmlDocument
class does read the entire file into memory. In my opinion, if you're trying to deal with XML files that large, you should probably be using something other than XML.Scott.
—In just two days, tomorrow will be yesterday. [Forum Guidelines] [Articles] [Blog]
-
I want to read a huge xml file and the node that i want to read is about to the middle of the file. Then also XPath is of to use?
Yes, XPath would be of use. XPath is the "query" language that allows you to retrieve a specific node or list of nodes. Think of it as working in a similar way to a SQL Select statement for a database.
Scott.
—In just two days, tomorrow will be yesterday. [Forum Guidelines] [Articles] [Blog]
-
I want to read a huge xml file and the node that i want to read is about to the middle of the file. Then also XPath is of to use?
What is the size of your xml file ? if its 1 GB like that then you hsould use xmlreader and dom in hand like this http://www.codeproject.com/useritems/XmlParsing.asp[^]
Thanks and Regards Sandeep If If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... "
-
Chintan.Desai wrote:
Scott is absolutely correct. XPath is fastest among all in parsing xml node.
YES he is. But if the XML file is pretty huge, then this method may take some time. I think XMLDocument class loads the entire XML file to the memory when it initializes. Am I right ?
ya, u r correct? but buddy loading xml and parsing both are completely different. Its work of different object. Its just lik this Building apartement is made by engineer, but its maintainance is depend on people who live ther. So, XPath is very fastest in parsing. Bye
Regards Chintan www.visharadsoft.com (I am thinking to change humans to computer, but unfortunately GOD will not give me the source code)
-
I want to read a huge xml file and the node that i want to read is about to the middle of the file. Then also XPath is of to use?
You may want to take a look at vtd-xml for that... http://vtd-xml.sf.net