Thread: C# XML generation

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    35

    C# XML generation

    How do I ensure that all of the namespaces I create for my document are displayed only once in the body of the topmost element, and that any references from then on display the prefix only? The way I have things set up at this point causes each namespace to be shown the first time it is referenced. How do I avoid this?

  2. #2
    Registered User
    Join Date
    May 2006
    Posts
    35
    Anyone have suggestions, or is more detail necessary in order to better understand the problem?

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    A set of flags to indicate whether the full namespace has been output (or not).
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    Registered User
    Join Date
    May 2006
    Posts
    35
    Quote Originally Posted by Salem View Post
    A set of flags to indicate whether the full namespace has been output (or not).
    I didn't mean to put emphasis on the fact that the namespaceuris be ouput only once because that actually happens. The namespaceuri appears once the first time the prefix is used, and then only the prefix thereafter. The idea is to have the first occurence for each namespaceuri to appear immdiately after the first element.

  5. #5
    Registered User
    Join Date
    May 2006
    Posts
    35
    I still don't have a solution to this. I would like my document to avoid referencing the namespaces unless it is a new namespace and it is the first mention of it. It makes my document appear sloppy.

  6. #6
    Registered User
    Join Date
    Sep 2007
    Location
    Adelaide, Australia
    Posts
    9
    Hi gotclout,

    Are you using System.Xml.XmlDocument, or XML Serialization?

  7. #7
    Registered User
    Join Date
    May 2006
    Posts
    35
    System.Xml.XmlDocument

  8. #8
    Registered User
    Join Date
    May 2006
    Posts
    35
    Can anyone help with this? The namespaces appearing all over my document are quite messy.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Parsing Xml
    By deviousdexter in forum C# Programming
    Replies: 7
    Last Post: 04-24-2009, 06:29 AM
  2. Dissecting an Excel XML spreadsheet
    By desmond5 in forum C++ Programming
    Replies: 1
    Last Post: 05-22-2008, 04:32 PM
  3. XML message generation
    By George2 in forum C# Programming
    Replies: 5
    Last Post: 05-15-2008, 06:09 AM
  4. XML and data exchange
    By seexml in forum C Programming
    Replies: 0
    Last Post: 04-27-2006, 03:02 PM
  5. Need help with this xml tree example
    By kzar in forum C Programming
    Replies: 1
    Last Post: 11-22-2004, 11:23 AM