guest31ro Posted May 25, 2003 Posted May 25, 2003 <?xml version="1.0"?> <!--Playlist Myplayer--> <!--Playlist --> <Playlist> <Video Id="0" Title="Title0" Time="Time00000" Path="Path003" /> <Video Id="1" Title="Title1" Time="Time10000" Path="Path103" /> <Video Id="2" Title="Title2" Time="Time20000" Path="Path203" /> <Video Id="3" Title="Title3" Time="Time30000" Path="Path303" /> <Video Id="4" Title="Title4" Time="Time40000" Path="Path403" /> <Video Id="5" Title="Title5" Time="Time50000" Path="Path503" /> <Video Id="6" Title="Title6" Time="Time60000" Path="Path603" /> <Video Id="7" Title="Title7" Time="Time70000" Path="Path703" /> <Video Id="8" Title="Title8" Time="Time80000" Path="Path803" /> <Video Id="9" Title="Title9" Time="Time90000" Path="Path903" /> <Video Id="10" Title="Title10" Time="Time100000" Path="Path1003" /> <Video Id="11" Title="Title11" Time="Time110000" Path="Path1103" /> <Video Id="12" Title="Title12" Time="Time120000" Path="Path1203" /> <Video Id="13" Title="Title13" Time="Time130000" Path="Path1303" /> <Video Id="14" Title="Title14" Time="Time140000" Path="Path1403" /> <Video Id="15" Title="Title15" Time="Time150000" Path="Path1503" /> <Video Id="16" Title="Title16" Time="Time160000" Path="Path1603" /> <Video Id="17" Title="Title17" Time="Time170000" Path="Path1703" /> <Video Id="18" Title="Title18" Time="Time180000" Path="Path1803" /> <Video Id="19" Title="Title19" Time="Time190000" Path="Path1903" /> </Playlist> I have something like this I would like to get this values in a loop in a c# program, but I don't kow how to read. Can someone help me with a code? Thanks. Quote
Moderators Robby Posted May 25, 2003 Moderators Posted May 25, 2003 I would consider changing the stucture of the xml to use elements, anyway, whatever suites you. this should get you started XmlTextReader tr; string path = "c:\test.xml"; tr = new XmlTextReader(path); FileStream fs = new FileStream(path,FileMode.Open); tr = new XmlTextReader (fs); string temp=""; while (!tr.EOF) { //read here } Quote Visit...Bassic Software
guest31ro Posted May 25, 2003 Author Posted May 25, 2003 the problem is I don't how the read function for an element and his atributs. Can someone help me with that? <Video Id="2" Title="Title2" Time="Time20000" Path="Path203" /> for example how do I get teh information from this tag... Thanks. Quote
wyrd Posted May 25, 2003 Posted May 25, 2003 The best way to find exactly what you're looking for is to go into the object browser and search for XmlTextReader, and take a look at its methods and properties. There's HasAttributes, MoveToNextAttribute, Name, Value, NodeType (which is an XmlNodeType enumerator).. all sorts of things. There is a great deal of flexibility with this class, and many ways to get what you're looking for. Quote Gamer extraordinaire. Programmer wannabe.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.