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. XML / XSL
  4. Force XML end tag to be on same line with start tag when InnerText is null [modified]

Force XML end tag to be on same line with start tag when InnerText is null [modified]

Scheduled Pinned Locked Moved XML / XSL
questioncsharpxmlhelp
4 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.
  • G Offline
    G Offline
    grichard
    wrote on last edited by
    #1

    Hello, I'm using C# 2008 to create XML files where some elements have null text values, as shown in the following code. nodeUnderTest.InnerText = ""; The problem is that the end tag is being placed on the following line, as shown below where nodeUnderTest is :

    Using C#, how can I force the start and end XML tags to either appear on the same line or merged as shown below? Thanks, Grant modified on Monday, April 20, 2009 4:01 PM

    modified on Monday, April 20, 2009 4:03 PM

    G 1 Reply Last reply
    0
    • G grichard

      Hello, I'm using C# 2008 to create XML files where some elements have null text values, as shown in the following code. nodeUnderTest.InnerText = ""; The problem is that the end tag is being placed on the following line, as shown below where nodeUnderTest is :

      Using C#, how can I force the start and end XML tags to either appear on the same line or merged as shown below? Thanks, Grant modified on Monday, April 20, 2009 4:01 PM

      modified on Monday, April 20, 2009 4:03 PM

      G Offline
      G Offline
      George L Jackson
      wrote on last edited by
      #2

      Don't set the nodeUnderTest.InnerText at all. Just create the element. Also, nodeUnderTest.InnerText=""; is being set to an empty string and not a null value.

      "We make a living by what we get, we make a life by what we give." --Winston Churchill

      G 1 Reply Last reply
      0
      • G George L Jackson

        Don't set the nodeUnderTest.InnerText at all. Just create the element. Also, nodeUnderTest.InnerText=""; is being set to an empty string and not a null value.

        "We make a living by what we get, we make a life by what we give." --Winston Churchill

        G Offline
        G Offline
        grichard
        wrote on last edited by
        #3

        When I set nodeUnderTest.InnerText = null, the start and end tags were once again placed on separate lines. When I commented out the nodeUnderTest.InnerText line, it placed the tags on the same line, but they were separated by a single space. I still need to determine how to either force the tags to be appear on the same line with no space in between or as the shortened version where the start and end tags are inclusive. Thanks.

        G 1 Reply Last reply
        0
        • G grichard

          When I set nodeUnderTest.InnerText = null, the start and end tags were once again placed on separate lines. When I commented out the nodeUnderTest.InnerText line, it placed the tags on the same line, but they were separated by a single space. I still need to determine how to either force the tags to be appear on the same line with no space in between or as the shortened version where the start and end tags are inclusive. Thanks.

          G Offline
          G Offline
          George L Jackson
          wrote on last edited by
          #4

          Post some code to show what you are doing.

          "We make a living by what we get, we make a life by what we give." --Winston Churchill

          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