大家好,又见面了,我是你们的朋友全栈君。
class
LocationCamera
public
LocationCamera()
private
string
name;
public
string
Name
get
{
return
name; }
set
{ name =
value
; }
private
int
duration;
public
int
Duration
get
{
return
duration; }
set
{ duration =
value
; }
private
double
roll;
//=”-4.29374881997575E-14″
public
double
Roll
get
{
return
roll; }
set
{ roll =
value
; }
private
double
tilt;
//=”-15.333841267255″
public
double
Tilt
get
{
return
tilt; }
set
{ tilt =
value
; }
private
double
heading;
//=”-50.5252574662688″
public
double
Heading
get
{
return
heading; }
set
{ heading =
value
; }
private
double
z;
//=”770.962000000316″
public
double
Z
get
{
return
z; }
set
{ z =
value
; }
private
double
y;
//=”24483.2877865981″
public
double
Y
get
{
return
y; }
set
{ y =
value
; }
private
double
x;
//=”10533.2696556843″
public
double
X
get
{
return
x; }
set
{ x =
value
; }
public
static
Hashtable
getCameraXml(
string
path)
Hashtable
hashtable =
new
Hashtable
();
if
(
File
.Exists(path))
XmlDocument
xmlDoc =
new
XmlDocument
();
if
(xmlDoc !=
null
)
XmlNodeList
nodelist = xmlDoc.SelectNodes(
“/CameraGroup/Camera”
);
LocationCamera类中
foreach
(
XmlNode
node
in
nodelist)
LocationCamera
locationCamera =
new
LocationCamera
();
“Name”
].Value.ToString();
Convert
.ToDouble(node.Attributes[
“roll”
].Value.ToString());
Convert
.ToDouble(node.Attributes[
“tilt”
].Value.ToString());
Convert
.ToDouble(node.Attributes[
“heading”
].Value.ToString());
Convert
.ToDouble(node.Attributes[
“x”
].Value.ToString());
Convert
.ToDouble(node.Attributes[
“y”
].Value.ToString());
Convert
.ToDouble(node.Attributes[
“z”
].Value.ToString());
Console
.WriteLine(node.OuterXml);
return
hashtable;
return
null
;
static
void
writeCameraXml(
string
path)
XmlDocument
xmlDoc =
new
XmlDocument
();
//创建Xml声明部分,即<?xml version=”1.0″ encoding=”utf-8″ ?>
“1.0”
,
“utf-8”
,
“yes”
);
//创建CameraGroup根节点
XmlNode
rootNode = xmlDoc.CreateElement(
“CameraGroup”
);
//创建WKT属性
XmlAttribute
wktAttribute = xmlDoc.CreateAttribute(
“WKT”
);
“UNKNOWNCS[\”unnamed\””
;
//为根节点添加属性
//创建Camera子节点
XmlNode
cameraNode = xmlDoc.CreateElement(
“Camera”
);
//创建Name属性
XmlAttribute
nameAttribute = xmlDoc.CreateAttribute(
“Name”
);
“分区1”
;
//为Camera添加属性
//创建X属性
XmlAttribute
xAttribute = xmlDoc.CreateAttribute(
“X”
);
“112.42342”
;
//为Camera添加X属性
//为根节点CameraGroup添加Camera子节点
//为Xml文档添加根元素
//保存Xml文件
//path为:@”d:\anxiuyun.xml”
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/150724.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...