mycwcgr

mycwcgr

  • NA
  • 13
  • 0

Is there a best way to store XML to database (SQL 2005 Express Edition)?

Sep 3 2005 7:14 PM

Is there a best way to store XML to database (SQL 2005 Express Edition)?

I'm doing a sample program about online bookmark, I have created two fields

UserID              Uniqueidentifier
ContentOfBookmark   I'm not sure what kind of field (ntext, XML or other field)


I plan to store the following XML content to the field ContentOfBookmark, first I set the ContentOfBookmark field as ntext type,
and restore the XML Content from the ContentOfBookmark field to a XML file, then use XMLReader to parse the XML file.

Now I heard there is a new XML field in SQL 2005 , but I don't know how to use it.

Do you think which kind of field I should use?
what I think about the bookmark is correct?

Is there a better way to resolve the hierarchical directory structure? If I store the structure in XML file, I think I can use many XML functions to operate bookmarks and folder easily such as add, delete bookmark; add delete folder...

 


========================== XML Content (ContentOfBookmark)============================================

<?xml version="1.0" encoding="utf-8" ?>
<Folder Name="Root" Id="a6dce8fe-749c-4e38-ab2f-3d03d9711b3d">
  <Bookmark>
    <Title>CodeGuru Forums - ASP.NET</Title>
    <Url>http://www.codeguru.com/</Url>
    <Description>This is a good site</Description>
    <InputDate> 2005-12-5</InputDate>
    <IsPrivate>False</IsPrivate>
  </Bookmark>

  <Bookmark>
    <Title>We'll e-mail your press release</Title>
    <Url>http://www.dpdirectory.com/</Url>
    <Description>This is a good site</Description>
    <InputDate> 2004-12-5</InputDate>
    <IsPrivate>False</IsPrivate>
  </Bookmark>

  <Folder Name="Card" Id="b8dcf8fe-749c-4e38-ab2f-6d03d9711b8j">

    <Bookmark>
      <Title>Welcome to the bank</Title>
      <Url>https://www.myepassporte.com/</Url>
      <Description>Very Good</Description>
      <InputDate> 2004-08-5</InputDate>
      <IsPrivate>True</IsPrivate>
    </Bookmark>

    <Bookmark>
      <Title>Keystone DreamCard</Title>
      <Url>https://www.mydreamcard.com</Url>
      <Description>Please note</Description>
      <InputDate> 2004-08-5</InputDate>
      <IsPrivate>True</IsPrivate>
    </Bookmark>   
 
  </Folder>

</Folder>

======================= XML Content (ContentOfBookmark)===============================================