LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Add attributes to existing XML elements in XML-File

Solved!
Go to solution

Hi,

I would like to "flatten" existing XML-Files with many "TestStep"-entries, from "old" to "new", by incorporating the Child-Entries "Attr" as an attribute into the normal entries.

old:

<TestReport

  <TestExecution

     <TestSteps>

        <TestStep measid="0220_0005" status="Passed">
              <Attr name="Infotext [Out]" type="String" value="[Request] 22 E0 68"/>
              <Attr name="Requirements" type="String" value="HighVariant" />
        </TestStep>

    <TestExecution

<TestReport

 

new:

<TestReport

  <TestExecution

     <TestSteps>

        <TestStep measid="0220_0005" status="Passed" Infotext="[Request] 22 E0 68" Requirements="HighVariant" />
        </TestStep>

    <TestExecution

<TestReport

 

I tried many approaches, but whenever i try to append an created "attribute" into an existing node LabView gives me an error.

 

Can anyone give me a hint?

 

This Code gives me Errorcode "-2607" 

Add_Attribute.jpg

0 Kudos
Message 1 of 4
(1,444 Views)

Here the VI (LV 2017) - but it does not work as mentioned above 🙂

0 Kudos
Message 2 of 4
(1,443 Views)
Solution
Accepted by Jo__Ho

Hi Jo,

 

Use method "Set Attribute" from class "Element":

raphschru_2-1695661654139.png

 

What you were trying to do may not work because XML attributes are unordered.

 

Regards,

Raphaël.

 

Message 3 of 4
(1,425 Views)

Hi Raphaël,

thank you so much for your extremly fast reply!

Your VI i worked perfectly - this is exactly what i needed!

 

I would have never come to the idea to use "force Type" -  i didn't even know that it existed 🙂

0 Kudos
Message 4 of 4
(1,367 Views)