alanchinese
Regular
- Joined
- Jan 12, 2005
- Messages
- 62
Hi,
Is there a simple and efficient way to create an XML from a segmented string?
For example, I would like to convert the following string (is there a better name for this kind of strings?):
into:
In this example,
Currently, we are reading and parsing these strings manually. I am wondering if there are existing ways (regular expressions, maybe?) so that we can convert them into XMLs.
We can do the following with the XMLs:
Thanks a lot for any information or suggestions,
Alan.
Is there a simple and efficient way to create an XML from a segmented string?
For example, I would like to convert the following string (is there a better name for this kind of strings?):
Code:
SEG_ROOT_START*1234~
SEG_LVL1*A*B~
SEG_LVL2*8~
SEG_LVL1*X*~
SEG_ROOT_END~
Code:
<SEG_ROOT>
<SEG_LVL1>
<SEG_LVL1_01>A</SEG_LVL1_01>
<SEG_LVL1_02>B</SEG_LVL1_02>
<SEG_LVL2>
<SEG_LVL2_01>8</SEG_LVL2_01>
</SEG_LVL2>
</SEG_LVL1>
<SEG_LVL1>
<SEG_LVL1_01>X</SEG_LVL1_01>
<SEG_LVL1_01 />
</SEG_LVL1>
</SEG_ROOT>
In this example,
- The root segment has two forms, one for begin, one for end. We need to parse this specially
- There are two levels, LVL1 (expecting two string childrens) and LVL2 (expecting one integer child)
- Level LVL2 can only be children of LVL1
- When an expected value shows an empty string, the corresponding XML node shouuld be NULL.
Currently, we are reading and parsing these strings manually. I am wondering if there are existing ways (regular expressions, maybe?) so that we can convert them into XMLs.
We can do the following with the XMLs:
- Data validation once XSD is defined.
- Data transformation once XSLT is defined.
- Data transmission via web services.
Thanks a lot for any information or suggestions,
Alan.