Results 1 to 3 of 3

Thread: Including XML Schema reference when XML file is created

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2004
    Posts
    87

    Unhappy Including XML Schema reference when XML file is created

    Hello All,

    I am just getting into vb.net and XML, a daunting task.

    I am creating an XML file from a recordset, but need to include references to XML schemas at the very beginning of the XML file.......how do I do that.

    I used the following as a test, but need to include the references to the schemas somehow.

    VB Code:
    1. mywriter = New System.Xml.XmlTextWriter(Server.MapPath("myfoo666.xml"), System.Text.Encoding.UTF8)
    2. With mywriter
    3. 'NEED SOMETHING IN HERE TO REFERENCE THE SCHEMA(.XSD) FILES...?????.....
    4. .WriteStartElement("MyBooks")
    5.             .WriteStartElement("Book")
    6.             .WriteAttributeString("ISBN", "1861005652")
    7.             .WriteAttributeString("Title", "How to make XML Work")
    8.             .WriteElementString("Author", "A. N. Other")
    9.             .WriteEndElement() 'For Book
    10.             .WriteEndElement()
    11. End With
    12.         mywriter.Flush()
    13.         mywriter.Close()

    Please, has anyone any ideas, I am struggling a bit.

    Many Thanks,

    Al...

  2. #2
    Fanatic Member
    Join Date
    Oct 2001
    Location
    Three Anchor Bay, Cape Town, South Africa
    Posts
    769

    Re: Including XML Schema reference when XML file is created

    You need 2 attributes as shown below:
    Code:
    <root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="schema.xsd">
      <node />
      <node />
      <node />
    </root>

  3. #3

    Thread Starter
    Lively Member
    Join Date
    May 2004
    Posts
    87

    Re: Including XML Schema reference when XML file is created

    Thanks Shunt,

    But I need to know how, or even if, you can create this dynamically at the top of the document, as I stated in my original post.

    I was thinking that maybe I could call a class, give it the physical path to my XSD file, and it would write it out at the top of my XML document, before I called the first WriteStartElement command.

    Any ideas.....?????

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