We have then traversed the nodes of the XML document by using the Read method of the XmlReader object in a while loop. Inside the loop, we have compared its NodeType with the values from the XmlNodeType enumeration for each node.
If it is a text node, we are write the text value to the console. In above code, we have checked if the current node is of type XmlNodeType. Element , and its name is city. If not, we move to the next node by using the Read method of the XmlReader object. If it is, then we will write all its attributes to the console. You must be logged in to post a comment. What is […]. Downloading multiple files in ASP. NET Solution: Here, we have […].
Asked 10 years, 11 months ago. Active 2 years, 2 months ago. Viewed 19k times. XML It hold these values.. How can do it using c?
Anuya Anuya 7, 46 46 gold badges silver badges bronze badges. Add a comment. Active Oldest Votes. This should work: using System. XML" ; xdoc. Descendants "EmployeeID". Value; xdoc. Descendants "EmployeeName". Parse xml. Element "EmployeeID". Element "EmployeeName".
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support. Feedback will be sent to Microsoft: By pressing the submit button, your feedback will be used to improve Microsoft products and services.
Privacy policy. The streamed information can come from kinds of sources, such as a byte stream from a server, a file, or a TextReader class. This example uses a file named Books. You can create your own Books. This file is also available for download; refer to the first item in the References section of this article for the download location. Create a new Visual C Console Application. You can either continue to the Complete code listing section or continue through these steps to build the application.
Specify the using directive on the System. Xml namespace so that you aren't required to qualify the XmlTextReader class declarations later in your code. You must use the using directive before any other declarations. Streams are used to provide independence from the device; thus, program changes aren't required if the source of a stream changes.
You'll use the constant in the next step with XmlTextReader.
0コメント