I'm trying to pull in
Expand|Select|Wrap|Line Numbers
- <tagX>123</tagX>
The way I'm supposed to find it is direct my program to pull that specific one based on what is encased in.
I want look inside
Expand|Select|Wrap|Line Numbers
- <Casing3></Casing3>
Basically it looks something like this:
Expand|Select|Wrap|Line Numbers
- <Casing1>
- <TagX>
- FALSE
- </TagX>
- <Casing1>
- *lines and lines of code*
- <Casing2>
- <TagX>
- FALSE
- </TagX>
- </Casing2>
- *lines and lines of code*
- <Casing3>
- <TagX>
- 123
- </TagX>
- </Casing3>
I need to point it to "Casing3" specifically.
I can't just use a continue statement to skip the first two, because there could be none or their could be 7 other "casings" before the "Casing3" in these different XML files.
I'm pulling in other tags that only occur once, and this is what the code looks like for them (this is just a segment of the working code. It's not clean or perfect, but so far it works)
Expand|Select|Wrap|Line Numbers
- {
- XPathNavigator mainDSNav = MainDataSource.CreateNavigator();
- string s = mainDSNav.SelectSingleNode("/my:myFields/my:XMLFile", NamespaceManager).Value; //reads xml file
- if (s == "")
- {
- }
- else
- {
- string result = Encoding.ASCII.GetString(InfoPathAttachmentDecoder(s));
- XmlDocument doc = new XmlDocument();
- doc.LoadXml(result);
- XmlNodeList list = doc.GetElementsByTagName("CAT"); //gets node "CAT" from the XML file
- XmlNodeList list2 = doc.GetElementsByTagName("DOG"); //gets node "DOG" from the XML file
- foreach (XmlNode node in list)
- {
- mainDSNav.SelectSingleNode("/my:myFields/my:catText", NamespaceManager).InnerXml += node.InnerText; //sends the value encased in node "CAT" to the "catText" field
- }
- foreach (XmlNode node in list2)
- {
- mainDSNav.SelectSingleNode("/my:myFields/my:dogText", NamespaceManager).InnerXml += node.InnerText; //sends the value encased in node "DOG" to the "dogText" field
- }
- }
- }
Any ideas?
(and if I'm using terms wrong, I apologize. This is my first project working with XML, so I'm learning as I go)