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 display/print name value in XML file

How to display/print name value in XML file

Scheduled Pinned Locked Moved ASP.NET
tutorialcsharpasp-netxmljson
6 Posts 4 Posters 1 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.
  • H Offline
    H Offline
    hm9
    wrote on last edited by
    #1

    I have a page in asp.net that queries an XML file and shows the data. It shows the data I need in the nodes, but I want to print the specific values deeper in the node… for instance I want to be able to print the value - PARIS or country France in the XML example below. with the line below I can only print the first element but I am not sure how to print the other values,Any advise on how this can be achieved? Note the rest of the code works and shows the other elements in the upper nodes, It s just I want to know how to display the name values or specific name value in the sample xml file below Asp.net Line Code: CityValue = node.SelectSingleNode("ns2:fields/ns2:field", nsManager).InnerText, _ XML:

    EUR

    3 Star

    FRANCE

    2.344952

    48.872646

    6950

    PARIS

    75009

    F Richard DeemingR P 3 Replies Last reply
    0
    • H hm9

      I have a page in asp.net that queries an XML file and shows the data. It shows the data I need in the nodes, but I want to print the specific values deeper in the node… for instance I want to be able to print the value - PARIS or country France in the XML example below. with the line below I can only print the first element but I am not sure how to print the other values,Any advise on how this can be achieved? Note the rest of the code works and shows the other elements in the upper nodes, It s just I want to know how to display the name values or specific name value in the sample xml file below Asp.net Line Code: CityValue = node.SelectSingleNode("ns2:fields/ns2:field", nsManager).InnerText, _ XML:

      EUR

      3 Star

      FRANCE

      2.344952

      48.872646

      6950

      PARIS

      75009

      F Offline
      F Offline
      F ES Sitecore
      wrote on last edited by
      #2

      Make sure the ns2 namespace is properly registered with the namespace manager. XmlNamespaceManager Class (System.Xml) | Microsoft Docs[^]

      H 1 Reply Last reply
      0
      • F F ES Sitecore

        Make sure the ns2 namespace is properly registered with the namespace manager. XmlNamespaceManager Class (System.Xml) | Microsoft Docs[^]

        H Offline
        H Offline
        hm9
        wrote on last edited by
        #3

        It s not a namespace issue. Everything works as far a namespace is concerned. I want to know how to drill to the name Attribute and get the values displayed. for instance, City or Zipcode values

        1 Reply Last reply
        0
        • H hm9

          I have a page in asp.net that queries an XML file and shows the data. It shows the data I need in the nodes, but I want to print the specific values deeper in the node… for instance I want to be able to print the value - PARIS or country France in the XML example below. with the line below I can only print the first element but I am not sure how to print the other values,Any advise on how this can be achieved? Note the rest of the code works and shows the other elements in the upper nodes, It s just I want to know how to display the name values or specific name value in the sample xml file below Asp.net Line Code: CityValue = node.SelectSingleNode("ns2:fields/ns2:field", nsManager).InnerText, _ XML:

          EUR

          3 Star

          FRANCE

          2.344952

          48.872646

          6950

          PARIS

          75009

          Richard DeemingR Offline
          Richard DeemingR Offline
          Richard Deeming
          wrote on last edited by
          #4

          Try:

          CityValue = node.SelectSingleNode("ns2:fields/ns2:field[@name='city']", nsManager).InnerText


          "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

          "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

          H 1 Reply Last reply
          0
          • Richard DeemingR Richard Deeming

            Try:

            CityValue = node.SelectSingleNode("ns2:fields/ns2:field[@name='city']", nsManager).InnerText


            "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

            H Offline
            H Offline
            hm9
            wrote on last edited by
            #5

            Thanks Richard. That's exactly what I was looking for :)

            1 Reply Last reply
            0
            • H hm9

              I have a page in asp.net that queries an XML file and shows the data. It shows the data I need in the nodes, but I want to print the specific values deeper in the node… for instance I want to be able to print the value - PARIS or country France in the XML example below. with the line below I can only print the first element but I am not sure how to print the other values,Any advise on how this can be achieved? Note the rest of the code works and shows the other elements in the upper nodes, It s just I want to know how to display the name values or specific name value in the sample xml file below Asp.net Line Code: CityValue = node.SelectSingleNode("ns2:fields/ns2:field", nsManager).InnerText, _ XML:

              EUR

              3 Star

              FRANCE

              2.344952

              48.872646

              6950

              PARIS

              75009

              P Offline
              P Offline
              Parth Munjpara
              wrote on last edited by
              #6
              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