Results 1 to 2 of 2

Thread: C# and XML **SOLVED**

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member Sgt-Peppa's Avatar
    Join Date
    Mar 2003
    Location
    Munich - Germany
    Posts
    476

    C# and XML **SOLVED**

    Ok, i am pretty new to C# and xml. I have a project where I need to read an XML File and get some Values

    first of all heres my xml Structure:
    <doctypes>
    <type>
    <name>one</name>
    <regexpression>testexp</regexpression>
    <containsbin>no</containsbin>
    </type>
    <type>
    <name>two</name>
    <regexpression>onemore</regexpression>
    <containsbin>no</containsbin>
    </type>
    </doctypes>

    Now what I do is read in my xml doc, run through all nodes and compare the Values to a "Flatfile". Once I found a regexpression in the flatfile I want to write the name of it to a variable. Heres what I do up till now:

    Code:
    						foreach(XmlNode n2 in docElement.ChildNodes) // for every childnode in doc_types  
    						{
    							if(n2.Name =="type") // if childnode is called type then
    							{
    								foreach(XmlNode n3 in n2.ChildNodes) // read all the attributes of that type
    								{	
    									//get the regexp and look in the doc if its there
    									if(n3.Name == "regexpression") 
    									{
    										string tmp = n3.InnerText;
    										if(rest.IndexOf(tmp) !=-1)
    										{
    										//get the node before that node and write the inner text to header
    										//break the first for each
    										}
    									}
    								} 
    							}
    						}
    So heres my question: Once I found the regular Expression in my Flatfile I want to get the Value of the node <name> wich is one node before the <regexpression> node. How can I select the that node without running through all my nodes again?

    Is that clear? Hope to hear from you guys,

    Thanx in advance Stephan
    Last edited by Sgt-Peppa; May 26th, 2003 at 04:48 AM.
    Keep Smiling - even if its hard
    Frankie Says Relax, wossname Says Yeah!
    wossname:--Currently I'm wearing a gimp suit and a parachute.
    C# - Base64 Blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width