【发布时间】:2020-06-11 13:23:11
【问题描述】:
我需要动态设置 xml 元素值。我几乎完成了它,但我需要在特定部分添加一个条件,它不起作用。 我有一个组件标签,其中有 2 个部分,第一个部分的代码 =“62387-6”,第二个部分的代码 =“47045-0”。 我需要在其中添加特定的标题和文本。
我尝试过的是:
(Declared)
Private _titleReferto As String = "Title Referto"
Private _testoReferto As String = "Testo Referto"
Private _titlePrestazione As String = "Title Prestazione"
Private _testoPrestazione As String = "Testo Prestazione"
(In the function that I invoke)
Me.setXmlValue(rootNode, Me._titleReferto, "//cr:component/cr:structuredBody/cr:component/cr:section/cr:code[@code='47045-0']/cr:title", NS)
Me.setXmlValue(rootNode, Me._testoReferto, "//cr:component/cr:structuredBody/cr:component/cr:section[code/@code='" + "47045-0" + "']/cr:text", NS)
Me.setXmlValue(rootNode, Me._titlePrestazione, "//cr:component/cr:structuredBody/cr:component/cr:section[code/@code='" + "62387-6" + "']/cr:title", NS)
Me.setXmlValue(rootNode, Me._testoPrestazione, "//cr:component/cr:structuredBody/cr:component/cr:section[code/@code='" + "62387-6" + "']/cr:text", NS)
这就是我需要的xml:
<component>
<structuredBody>
<component>
<section>
<code code="62387-6" codeSystem="2.16.840.1.113883.6.1" codeSystemName="LOINC" codeSystemVersion="2.64" displayName="Interventi" /> <!-- OBBL-->
<title> Title Prestazione </title> <!-- OBBL-->
<text> <!-- OBBL-->
<paragraph>
<caption>Testo Prestazione</caption>
</paragraph>
</text>
</section>
</component>
<component>
<section>
<code code="47045-0" codeSystem="2.16.840.1.113883.6.1" codeSystemName="LOINC" codeSystemVersion="2.64" displayName="Referto" /> <!-- OBBL-->
<title> Title Referto </title> <!-- OBBL-->
<text> <!-- OBBL-->
<paragraph>
Testo Referto
</paragraph>
</text>
</section>
</component>
</structuredBody>
</component>
【问题讨论】: