| |

VerySource

 Forgot password?
 Register
Search
View: 859|Reply: 4

Generate xml

[Copy link]

3

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-12-16 18:30:02
| Show all posts |Read mode
<items>
  <item Text="News" NavigateUrl="WebForm1.aspx" DefaultSubItemLookId="Level2Tab" DefaultSubItemSelectedLookId="SelectedLevel2Tab">
    <item Text="Top Stories" NavigateUrl="WebForm1.aspx?page=top_stories" />
    <item Text="Breaking News" NavigateUrl="WebForm1.aspx?page=breaking_news" />
    <item Text="World News" NavigateUrl="WebForm1.aspx?page=world_news" />
  </item>
</items>

How do I generate it?? News, Markets, Travel, Travel2016 are read from the database, and the following <item Text="News" NavigateUrl="WebForm1.aspx" DefaultSubItemLookId="Level2Tab" DefaultSubItemSelectedLookId="SelectedLevel2Tab" >
    <item Text="Top Stories" NavigateUrl="WebForm1.aspx?page=top_stories" />
    <item Text="Breaking News" NavigateUrl="WebForm1.aspx?page=breaking_news" />
    <item Text="World News" NavigateUrl="WebForm1.aspx?page=world_news" />
  </item>
Reply

Use magic Report

0

Threads

21

Posts

12.00

Credits

Newbie

Rank: 1

Credits
12.00

 China

Post time: 2020-12-17 11:45:01
| Show all posts
I didn't understand it. However, I want to use the writexml method of dataset or datatable.
Reply

Use magic Report

3

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 Invalid IP Address

 Author| Post time: 2020-12-18 15:45:01
| Show all posts
<items>
  <item Text="News" NavigateUrl="WebForm1.aspx" DefaultSubItemLookId="Level2Tab" DefaultSubItemSelectedLookId="SelectedLevel2Tab">
    <item Text="Top Stories" NavigateUrl="WebForm1.aspx?page=top_stories" />
    <item Text="Breaking News" NavigateUrl="WebForm1.aspx?page=breaking_news" />
    <item Text="World News" NavigateUrl="WebForm1.aspx?page=world_news" />
  </item>

  <item Text="Markets" NavigateUrl="WebForm1.aspx?page=markets" DefaultSubItemLookId="Level2Tab" DefaultSubItemSelectedLookId="SelectedLevel2Tab">
    <item Text="Commentary" NavigateUrl="WebForm1.aspx?page=commentary" />
    <item Text="Technology" NavigateUrl="WebForm1.aspx?page=technology" />
    <item Text="Personal Finance" NavigateUrl="WebForm1.aspx?page=personal_finance" />
    <item Text="Mutual Funds" NavigateUrl="WebForm1.aspx?page=mutual_funds" />
  </item>

  <item Text="Showbiz" NavigateUrl="WebForm1.aspx?page=showbiz" DefaultSubItemLookId="Level2Tab" DefaultSubItemSelectedLookId="SelectedLevel2Tab">
    <item Text="Movies" NavigateUrl="WebForm1.aspx?page=movies" />
    <item Text="Music" NavigateUrl="WebForm1.aspx?page=music" />
    <item Text="Television" NavigateUrl="WebForm1.aspx?page=television" />
    <item Text="Books" NavigateUrl="WebForm1.aspx?page=books" />
    <item Text="Video | Audio" NavigateUrl="WebForm1.aspx?page=video_audio" />
  </item>

  <item Text="Travel" NavigateUrl="WebForm1.aspx?page=travel" DefaultSubItemLookId="Level2Tab" DefaultSubItemSelectedLookId="SelectedLevel2Tab">
    <item Text="Destinations" NavigateUrl="WebForm1.aspx?page=destinations" />
    <item Text="Agencies" NavigateUrl="WebForm1.aspx?page=agencies" />
    <item Text="Photo of the Day" NavigateUrl="WebForm1.aspx?page=photo_of_the_day" />
  </item>

  <item Text="Travel2016" NavigateUrl="WebForm1.aspx?page=travel200" DefaultSubItemLookId="Level2Tab" DefaultSubItemSelectedLookId="SelectedLevel2Tab">
    <item Text="Destinations22" NavigateUrl="WebForm1.aspx?page=destinations" />
    <item Text="Agencies2016" NavigateUrl="WebForm1.aspx?page=agencies" />
    <item Text="Photo of the Day2016" NavigateUrl="WebForm1.aspx?page=photo_of_the_day" />
  </item>
</items>

News, Markets, Travel, Travel2016 are read from the database, and the following <item Text="News" NavigateUrl="WebForm1.aspx" DefaultSubItemLookId="Level2Tab" DefaultSubItemSelectedLookId="SelectedLevel2Tab">
    <item Text="Top Stories" NavigateUrl="WebForm1.aspx?page=top_stories" />
    <item Text="Breaking News" NavigateUrl="WebForm1.aspx?page=breaking_news" />
    <item Text="World News" NavigateUrl="WebForm1.aspx?page=world_news" />
  </item>
Reply

Use magic Report

0

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-12-18 16:45:01
| Show all posts
DataTable dt=Query data;

//According to News, Markets, Travel, Travel2016 conditions to determine the looped spelling string

string s="";

for(int i=0;i<dt.Rows.Count;i++)
{
   if(dt.Rows[i]["new"].ToString()=="new")
   {
     s+="<item>+";
     s+="<item Text="+News+" ... >+";
     s+="...+";
     s+="...+";
     s+="</item>";
   }
   if(dt.Rows[i]["Markets"]=="Markets")
   {
     s+="<item>+";
     s+="<item Text="+Markets+" ... >+";
     s+="...+";
     s+="...+";
     s+="</item>";
   }
...
...

}

//Write xml with io

StreamWriter sw=new StreamWriter( Server.MapPath("")+"/"+filename+".xml",false,System.Text.Encoding.GetEncoding("GB2312"));

sw.Write(s);
            
sw.Close();
Reply

Use magic Report

0

Threads

58

Posts

32.00

Credits

Newbie

Rank: 1

Credits
32.00

 China

Post time: 2020-12-18 17:00:01
| Show all posts
Refer to select ... for xml syntax.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list