【发布时间】:2018-04-26 00:02:19
【问题描述】:
我想创建一个带有以下 .txt 的 XML 文件。
以下对象具有相同的结构。是否可以创建 XML?
我不需要 .txt 的全部内容。只有“信息 ObjectX、Delta X、Delta Y、Delta Z、所有旋转、CALLOUT 和 PART_TYPE”是重要且必要的。
最好的情况是,我想直接在 C# 程序中转换这些文件。
感谢您的帮助!
============================================================
Created by : Muster
Date : 13.11.2017 10:10:10
Activated component : File
Node name : abc123abc
============================================================
Information Object # 1
Name Object1
File-Path FilePath
Component-Path Component-Path
Typ Component
Color 2 (Green)
Component-Typ Body
Version 301 01 Jan 2017 10:10 (Created by Muster)
Object is visible
Positions:
Delta X = 5.00000000010
Delta Y = 16.0000000001
Delta Z = 20.0000000200
Rotations:
X-vector XC = 0.0 X = 0.0
YC = 1.0 Y = 1.0
ZC = 0.0 Z = 0.0
Y-vector XC = -1.0 X = -1.0
YC = 0.0 Y = 0.0
ZC = 0.0 Z = 0.0
Z-vektor XC = 0.0 X = 0.0
YC = 0.0 Y = 0.0
ZC = 1.0 Z = 1.0
Component is xxx
3 Rotations- and Translations available
------------------------------------------------------------
------------------------------------------------------------
CALLOUT = 4890 (string)
PART_NAME = body head (string)
PART_TYPE = Item (string)
************************************************************
Information Object # 2
Name Object2
File-Path FilePath
Component-Path Component-Path
Typ Component
Color 2 (Green)
Component-Typ Body
Version 301 01 Jan 2017 10:10 (Created by Muster)
Object is visible
Positions:
Delta X = 5.00000000010
Delta Y = 25.0000000000
Delta Z = 20.000000200
Rotations:
X-vector XC = 0.0 X = 0.0
YC = 1.0 Y = 1.0
ZC = 0.0 Z = 0.0
Y-vector XC = -1.0 X = -1.0
YC = 0.0 Y = 0.0
ZC = 0.0 Z = 0.0
Z-vektor XC = 0.0 X = 0.0
YC = 0.0 Y = 0.0
ZC = 1.0 Z = 1.0
Component is xxx
3 Rotations- and Translations available
------------------------------------------------------------
------------------------------------------------------------
CALLOUT = 4891 (string)
PART_NAME = body head (string)
PART_TYPE = Item (string)
【问题讨论】:
-
是否可以创建 XML?是的。您可以解析文件以获取所需的内容,然后将其写入 xml。你有没有尝试过?
-
我仍然尝试将其转换为 XML 文件。我不可能只解析我想要的内容,也无法为我的 XML 创建正确的结构。你有我的例子,我如何选择我想要的内容并将其插入到 XML 中?
-
Here is a question that shows how to parse a text file。您可以读取所需的行并创建一个表示 xml 数据结构的对象,然后可以将其写入 xml。
-
谢谢,它会帮助我一点点。我认为我的示例与此有些不同。如果你给我一个例子,可能是“Delta X”或“PART_TYPE”行,这会是一个问题吗?这对我很有帮助
-
您是否正在寻找一种方法来了解每一行的实际内容?尝试查看正则表达式的主题。