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. how to get data from xml?

how to get data from xml?

Scheduled Pinned Locked Moved ASP.NET
wpfwcfsysadminxmltutorial
5 Posts 5 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.
  • S Offline
    S Offline
    srisairam
    wrote on last edited by
    #1

    Hi all , i have one xml file, format is: <?xml version="1.0" encoding="utf-8" ?> <catalog> <timezone> <text>sudheer</text> <value>30</value> <text>radha</text> <value>50</value> <text>mayur</text> <value>55</value> </timezone> </catalog> i am binding like this in .cs file: XmlDocument doc = new XmlDocument(); doc.Load(Server.MapPath("~/App_Data/timezoneval.xml")); XmlNodeList _name = doc.GetElementsByTagName("text"); so i am passing that _name as input parameter to my method public string getname(string _name) { // } how to get value from xml using that text. if anybody knows please let me know Regards Rama

    M N T R 4 Replies Last reply
    0
    • S srisairam

      Hi all , i have one xml file, format is: <?xml version="1.0" encoding="utf-8" ?> <catalog> <timezone> <text>sudheer</text> <value>30</value> <text>radha</text> <value>50</value> <text>mayur</text> <value>55</value> </timezone> </catalog> i am binding like this in .cs file: XmlDocument doc = new XmlDocument(); doc.Load(Server.MapPath("~/App_Data/timezoneval.xml")); XmlNodeList _name = doc.GetElementsByTagName("text"); so i am passing that _name as input parameter to my method public string getname(string _name) { // } how to get value from xml using that text. if anybody knows please let me know Regards Rama

      M Offline
      M Offline
      Murugesan G
      wrote on last edited by
      #2

      try with

      nameNode.NextSibling

      or else go with xmlreader

      1 Reply Last reply
      0
      • S srisairam

        Hi all , i have one xml file, format is: <?xml version="1.0" encoding="utf-8" ?> <catalog> <timezone> <text>sudheer</text> <value>30</value> <text>radha</text> <value>50</value> <text>mayur</text> <value>55</value> </timezone> </catalog> i am binding like this in .cs file: XmlDocument doc = new XmlDocument(); doc.Load(Server.MapPath("~/App_Data/timezoneval.xml")); XmlNodeList _name = doc.GetElementsByTagName("text"); so i am passing that _name as input parameter to my method public string getname(string _name) { // } how to get value from xml using that text. if anybody knows please let me know Regards Rama

        N Offline
        N Offline
        Not Active
        wrote on last edited by
        #3

        You can use XPath to extract the node(s) you are looking for doc.SelectNodes("timezone[text=" + _name + "]"); (May not be 100% correct, but you get the idea)


        I know the language. I've read a book. - _Madmatt

        1 Reply Last reply
        0
        • S srisairam

          Hi all , i have one xml file, format is: <?xml version="1.0" encoding="utf-8" ?> <catalog> <timezone> <text>sudheer</text> <value>30</value> <text>radha</text> <value>50</value> <text>mayur</text> <value>55</value> </timezone> </catalog> i am binding like this in .cs file: XmlDocument doc = new XmlDocument(); doc.Load(Server.MapPath("~/App_Data/timezoneval.xml")); XmlNodeList _name = doc.GetElementsByTagName("text"); so i am passing that _name as input parameter to my method public string getname(string _name) { // } how to get value from xml using that text. if anybody knows please let me know Regards Rama

          T Offline
          T Offline
          T M Gray
          wrote on last edited by
          #4

          _name is not a string, it is an XmlNodeList. That shouldn't even compile. Loop through the NodeList and for each node get the InnerText. You can find an example on the first page of google search results for "XmlNodeList". Also, you might want to revise your XML schema. If you want each text element to be associated with the value element following it they should be encapsulated in another element. Order is not always guaranteed in XML parsing.

          1 Reply Last reply
          0
          • S srisairam

            Hi all , i have one xml file, format is: <?xml version="1.0" encoding="utf-8" ?> <catalog> <timezone> <text>sudheer</text> <value>30</value> <text>radha</text> <value>50</value> <text>mayur</text> <value>55</value> </timezone> </catalog> i am binding like this in .cs file: XmlDocument doc = new XmlDocument(); doc.Load(Server.MapPath("~/App_Data/timezoneval.xml")); XmlNodeList _name = doc.GetElementsByTagName("text"); so i am passing that _name as input parameter to my method public string getname(string _name) { // } how to get value from xml using that text. if anybody knows please let me know Regards Rama

            R Offline
            R Offline
            raghuv9246
            wrote on last edited by
            #5

            Thanks for sharing the procedure and the code for xml,ir was really hlpfull for me as i am new to it. Reverse Phone Lookup [Availing Payday Loans](http://www.paydayloansolutions.net/blog/top-6-reasons-for-availing-pay-day-loans

            )

            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