LoginSignup
0
0

cscの作法 その477

Last updated at Posted at 2024-04-05

概要

cscの作法、調べてみた。
練習問題やってみた。

練習問題

treeviewで、xmlを表示せよ。

方針

  • qiitaのfeed使う。

写真

image.png

サンプルコード


using System.Collections;
using System.Collections.Generic;
using System.IO;
using System;
using System.Text;
using System.Data;
using System.Windows.Forms;
using System.Drawing;
using System.Net;
using System.Net.Http;
using System.Xml;
using System.Xml.Linq;


class FormMain: Form {
	private TreeView tv;
	FormMain() {
		Text = "xml";
		Size = new Size(700, 700);
		tv = new TreeView();
		tv.Location = new Point(20, 20);
		tv.Size = new Size(600, 600);
		ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
		XNamespace xNamespace = @"http://www.w3.org/2005/Atom";
		var feed = XDocument.Load(@"https://qiita.com/popular-items/feed");
		//Console.WriteLine(feed);
		tv.Nodes.Add(CreateTreeNode(feed.Root));
		this.Controls.Add(tv);
	}
	private TreeNode CreateTreeNode(XElement elCurr) {
		TreeNode tnCurr = new TreeNode(elCurr.Value.ToString());
		if (elCurr.HasElements)
		{
			foreach (var elChild in elCurr.Elements())
			{
				tnCurr.Nodes.Add(CreateTreeNode(elChild));
			}
		}
		return tnCurr;
	}
	[STAThread]
	public static void Main() {
		Application.EnableVisualStyles();
		Application.SetCompatibleTextRenderingDefault(false);
		Application.Run(new FormMain());
	}
}






以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0