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. How limitate the attribute of the root to it?

How limitate the attribute of the root to it?

Scheduled Pinned Locked Moved XML / XSL
helpxmlquestion
2 Posts 2 Posters 10 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.
  • P Offline
    P Offline
    Pierre besquent
    wrote on last edited by
    #1

    Hi, I have this code to generate xml file;

    XmlTextWriter myXmlTextWriter = new XmlTextWriter ("D:/New Folder/MyXmlff.xml",System.Text.Encoding.UTF8);
    myXmlTextWriter.Formatting = Formatting.Indented;
    myXmlTextWriter.WriteStartDocument(false);
    myXmlTextWriter.WriteStartElement("root");
    myXmlTextWriter.WriteAttributeString("xmlns","urn:iso:std:iso:20022:tech:xsd:pain.001.001.02");
    myXmlTextWriter.WriteStartElement("pain.001.001.02");
    myXmlTextWriter.WriteComment("Section A : Group Header");
    myXmlTextWriter.WriteStartElement("GrpHdr");
    myXmlTextWriter.WriteStartElement("MsgId");
    myXmlTextWriter.Flush();
    myXmlTextWriter.WriteEndElement();
    myXmlTextWriter.WriteEndElement();
    myXmlTextWriter.Close();

    the problem is the attribute of the root appears always in other tags like this: </Salarié> </pain.001.001.02> </root> but i want that xmlns appears ONLY as an attribute of the root like this: FVIR/101230/1 2010-12-30T17:02:21 thank u for u help hugs false

    D 1 Reply Last reply
    0
    • P Pierre besquent

      Hi, I have this code to generate xml file;

      XmlTextWriter myXmlTextWriter = new XmlTextWriter ("D:/New Folder/MyXmlff.xml",System.Text.Encoding.UTF8);
      myXmlTextWriter.Formatting = Formatting.Indented;
      myXmlTextWriter.WriteStartDocument(false);
      myXmlTextWriter.WriteStartElement("root");
      myXmlTextWriter.WriteAttributeString("xmlns","urn:iso:std:iso:20022:tech:xsd:pain.001.001.02");
      myXmlTextWriter.WriteStartElement("pain.001.001.02");
      myXmlTextWriter.WriteComment("Section A : Group Header");
      myXmlTextWriter.WriteStartElement("GrpHdr");
      myXmlTextWriter.WriteStartElement("MsgId");
      myXmlTextWriter.Flush();
      myXmlTextWriter.WriteEndElement();
      myXmlTextWriter.WriteEndElement();
      myXmlTextWriter.Close();

      the problem is the attribute of the root appears always in other tags like this: </Salarié> </pain.001.001.02> </root> but i want that xmlns appears ONLY as an attribute of the root like this: FVIR/101230/1 2010-12-30T17:02:21 thank u for u help hugs false

      D Offline
      D Offline
      dasblinkenlight
      wrote on last edited by
      #2

      I assume this is a small fragment of your code, not the entire body of the method. Does the number of calls to WriteEndElement in your program match the number of calls to WriteStartElement?

      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