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. Web Development
  3. ASP.NET
  4. getting next xml node value

getting next xml node value

Scheduled Pinned Locked Moved ASP.NET
xmlhelp
6 Posts 2 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.
  • B Offline
    B Offline
    bhattiprolu
    wrote on last edited by
    #1

    hi, i have next and previous buttons, when i click next i must get the next xml node value and if i click previous button it should display the previous node value. can anybody help in this regard. Thanks in advance.

    S 1 Reply Last reply
    0
    • B bhattiprolu

      hi, i have next and previous buttons, when i click next i must get the next xml node value and if i click previous button it should display the previous node value. can anybody help in this regard. Thanks in advance.

      S Offline
      S Offline
      SeMartens
      wrote on last edited by
      #2

      If you have a XmlNode-instance you can use PreviousSibling and NextSibling. Have a look here: http://msdn.microsoft.com/de-de/library/system.xml.xmlnode.nextsibling.aspx[^] Regards Sebastian

      It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.

      B 1 Reply Last reply
      0
      • S SeMartens

        If you have a XmlNode-instance you can use PreviousSibling and NextSibling. Have a look here: http://msdn.microsoft.com/de-de/library/system.xml.xmlnode.nextsibling.aspx[^] Regards Sebastian

        It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.

        B Offline
        B Offline
        bhattiprolu
        wrote on last edited by
        #3

        hi, thanks for the help. Actually i have a webpage which contains previous and next buttons. in the same page i have a frame where i have to change the value of the iframe src depending on the previous and next buttons. the value will be taken from XML node values. Please check the xml doc below. <?xml version="1.0" encoding="utf-8" ?> <portfolio> <portfolios id="0808"> <src link="http://www.yahoo.com"></src> </portfolios> <portfolios id="0809"> <src link="http://www.gmail.com"></src> </portfolios> <portfolios id="0810"> <src link="http://www.codeproject.com></src> </portfolios> <portfolios id="0811"> <src link="http://www.xyz.com"></src> </portfolios> </portfolio> and check my backend coding. protected void imgbtnNext_Click(object sender, ImageClickEventArgs e) { //string crnturl = Request.Url.ToString(); XmlDocument doc=new XmlDocument(); XmlNode root = doc.LastChild; if (root) { imgbtnNext.Enabled = false; } else { string myurl = Request.QueryString.Get("id").ToString(); XmlDataSource xsd = new XmlDataSource(); xsd.DataFile = "~/App_Data/portfolio.xml"; xsd.XPath = "portfolio/portfolios[@id='" + myurl + "']/src"; GridView ds = new GridView(); ds.DataSource = xsd; ds.DataBind(); iframeprojects.Attributes.Add("src", ds.Rows[0].Cells[0].Text.ToString()); } }

        S 1 Reply Last reply
        0
        • B bhattiprolu

          hi, thanks for the help. Actually i have a webpage which contains previous and next buttons. in the same page i have a frame where i have to change the value of the iframe src depending on the previous and next buttons. the value will be taken from XML node values. Please check the xml doc below. <?xml version="1.0" encoding="utf-8" ?> <portfolio> <portfolios id="0808"> <src link="http://www.yahoo.com"></src> </portfolios> <portfolios id="0809"> <src link="http://www.gmail.com"></src> </portfolios> <portfolios id="0810"> <src link="http://www.codeproject.com></src> </portfolios> <portfolios id="0811"> <src link="http://www.xyz.com"></src> </portfolios> </portfolio> and check my backend coding. protected void imgbtnNext_Click(object sender, ImageClickEventArgs e) { //string crnturl = Request.Url.ToString(); XmlDocument doc=new XmlDocument(); XmlNode root = doc.LastChild; if (root) { imgbtnNext.Enabled = false; } else { string myurl = Request.QueryString.Get("id").ToString(); XmlDataSource xsd = new XmlDataSource(); xsd.DataFile = "~/App_Data/portfolio.xml"; xsd.XPath = "portfolio/portfolios[@id='" + myurl + "']/src"; GridView ds = new GridView(); ds.DataSource = xsd; ds.DataBind(); iframeprojects.Attributes.Add("src", ds.Rows[0].Cells[0].Text.ToString()); } }

          S Offline
          S Offline
          SeMartens
          wrote on last edited by
          #4

          Hmmm, seems a bit complicated. Why not loading the document and the use Xpath?

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

          XmlNode oCurNode = doc.SelectSingleNodes("portfolio/portfolios[@id='" + myurl + "']/src");
          iframeprojects.Attributes.Add("src", oCurNode.Attributes["link"].InnerText);

          Best would be to pass the id of the current node, so that you can find the next one. Regards Sebastian

          It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.

          B 1 Reply Last reply
          0
          • S SeMartens

            Hmmm, seems a bit complicated. Why not loading the document and the use Xpath?

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

            XmlNode oCurNode = doc.SelectSingleNodes("portfolio/portfolios[@id='" + myurl + "']/src");
            iframeprojects.Attributes.Add("src", oCurNode.Attributes["link"].InnerText);

            Best would be to pass the id of the current node, so that you can find the next one. Regards Sebastian

            It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.

            B Offline
            B Offline
            bhattiprolu
            wrote on last edited by
            #5

            hi thanks Sebastian, Nut i didn't get how to get the next node value.

            S 1 Reply Last reply
            0
            • B bhattiprolu

              hi thanks Sebastian, Nut i didn't get how to get the next node value.

              S Offline
              S Offline
              SeMartens
              wrote on last edited by
              #6

              Extend the code as following to get the next node id:

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

              XmlNode oCurNode = doc.SelectSingleNodes("portfolio/portfolios[@id='" + id + "']/src");
              iframeprojects.Attributes.Add("src", oCurNode.Attributes["link"].InnerText);

              // get next node (this will be a portfolio)
              XmlNode oNextNode = oCurNode.NextSibling;
              // get the id attribute
              string sNextId = oNextNode.Attributes["id"].InnerText;

              Then save the sNextId somewhere so that on the next button click you can use it. Regards Sebastian

              It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.

              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