Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. [Message Deleted]

[Message Deleted]

Scheduled Pinned Locked Moved C#
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    arkiboys
    wrote on last edited by
    #1

    [Message Deleted]

    N K 2 Replies Last reply
    0
    • A arkiboys

      [Message Deleted]

      N Offline
      N Offline
      N a v a n e e t h
      wrote on last edited by
      #2

      Since DOC node doesn't have child, you only need one loop which iterates the child nodes of BIBLE. See the following code

      for (int i = 0; i < bNode.ChildNodes.Count; i++)
      {
      XmlNode node = bNode.ChildNodes[i];
      string strElement = node.Name;
      if (strElement.ToLower().Trim() == "doc")
      {
      string strDocClientID = node.Attributes["CLIENT_ID"].Value;
      string strDocMatterID = node.Attributes["MATTER_ID"].Value;
      string strDocNumber = node.Attributes["DOCNUMBER"].Value;
      string strDocName = node.Attributes["DOCNAME"].Value;
      }
      }

      This can be done in a better way if you use XPath. :)

      Navaneeth How to use google | Ask smart questions

      A 1 Reply Last reply
      0
      • A arkiboys

        [Message Deleted]

        K Offline
        K Offline
        Karmendra Suthar
        wrote on last edited by
        #3

        Get a XmlElement and SelectSingleNode of that, instead of the XmlDocument. I am not sure why it is returning SECOND, I am beginner, I had this information thought of sharing, might help you, Let me know if it do help.

        XmlDocument doc = new XmlDocument();
        doc.Load(strFullPath);

        **XmlElement root = doc.DocumentElement;

        XmlNode bNode = root.SelectSingleNode("BIBLE");**

        string strBibleClientID = doc.DocumentElement.GetAttribute("CLIENT_ID");
        string strBibleMatterID = doc.DocumentElement.GetAttribute("MATTER_ID");
        string strBibleDocNumber = doc.DocumentElement.GetAttribute("DOCNUMBER");

        for (int i = 0; i < bNode.ChildNodes.Count; i++)
        {
        XmlNode bibleNode = bNode.ChildNodes[i];

        //number of elements per Bible...
        int intElements = bibleNode.ChildNodes.Count;

        //Go through the BIBLE node...
        for (int x = 0; x < intElements; x++)
        {
        //pull out each element...
        string strElement = bibleNode.ChildNodes[x].Name.ToString();

        if (strElement.ToLower().Trim() == "doc")
        {
        string strDocClientID = bibleNode.ChildNodes[x].Attributes["CLIENT_ID"].Value;
        string strDocMatterID = bibleNode.ChildNodes[x].Attributes["MATTER_ID"].Value;
        string strDocNumber = bibleNode.ChildNodes[x].Attributes["DOCNUMBER"].Value;
        string strDocName = bibleNode.ChildNodes[x].Attributes["DOCNAME"].Value;

        }
        }
        }

        1 Reply Last reply
        0
        • N N a v a n e e t h

          Since DOC node doesn't have child, you only need one loop which iterates the child nodes of BIBLE. See the following code

          for (int i = 0; i < bNode.ChildNodes.Count; i++)
          {
          XmlNode node = bNode.ChildNodes[i];
          string strElement = node.Name;
          if (strElement.ToLower().Trim() == "doc")
          {
          string strDocClientID = node.Attributes["CLIENT_ID"].Value;
          string strDocMatterID = node.Attributes["MATTER_ID"].Value;
          string strDocNumber = node.Attributes["DOCNUMBER"].Value;
          string strDocName = node.Attributes["DOCNAME"].Value;
          }
          }

          This can be done in a better way if you use XPath. :)

          Navaneeth How to use google | Ask smart questions

          A Offline
          A Offline
          arkiboys
          wrote on last edited by
          #4

          Hi, This only returns the data from the first DOC only Any thoughts please? Thanks

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups