CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    May 2006
    Posts
    306

    More XmlDocument Help, attribute trouble!

    Okay, so when I save a document with a blank attribute like this.

    Code:
    <Attrib></Attrib>
    It comes out looking like this.

    Code:
    <Attrib>
    </Attrib>
    Is there any way to prevent this?
    Last edited by code?; January 3rd, 2009 at 09:46 PM.

  2. #2
    Join Date
    Sep 2008
    Location
    Netherlands
    Posts
    865

    Re: More XmlDocument Help, save options?

    I don't know if there is anyway to prevent it, but if the element is empty you could also use
    Code:
    <Attrib/>

  3. #3
    Join Date
    May 2006
    Posts
    306

    Re: More XmlDocument Help, save options?

    That's a negative, it won't work that way for the situation I'm in.

  4. #4
    Join Date
    May 2006
    Posts
    306

    Re: More XmlDocument Help, save options?

    Nothing? Are you serious?

  5. #5
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125

    Re: More XmlDocument Help, save options?

    Quote Originally Posted by code? View Post
    That's a negative, it won't work that way for the situation I'm in.
    First, that is an element, NOT an attribute.

    Second, if your code does not work with all variations equally well, then you are not standards compliant.

    With increasing processing happening to XML content at varying levels, we are seeing more and more variations in format. Providing data contains (or references) a valid schema, and conforms to that schema, NOTHING else should matter.

    There are a number of "fuzzing" tools available (they make psuedo random changes to your data that do NOT impact the schema) to help test this aspect.
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  6. #6
    Join Date
    May 2006
    Posts
    306

    Re: More XmlDocument Help, save options?

    Well, I seem to have found a solution. I set PreserveWhitespace to true (or false) and it made the document all one line.

    It turns out, that the other program that reads the Xml, the file doesn't need to be fancy.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured