LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Add attributes to root XML Node

Solved!
Go to solution

I have seen this discussion, and the methodology doesn't seem to translate: https://forums.ni.com/t5/LabVIEW/XML-Attribute/td-p/791406

 

I'd like to set the attributes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" and xsi:schemaLocation="/path/to/schema" in the root node. The original XML is here:

 

 

<?xml version="1.0" encoding="utf-8"?>
<root xmlns="http://example.com/XMLSchema/schema.xsd">
<child/>
</root>

The desired XML is here:

 

 

<?xml version="1.0" encoding="utf-8"?>
<root xmlns="http://example.com/XMLSchema/schema.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="C:\path\to\schema http://example.com/XMLSchema/schema.xsd">
<child/>
</root>

My attempt (one of many, definitely wrong) is here:

 

xml root node add.png

0 Kudos
Message 1 of 2
(2,740 Views)
Solution
Accepted by topic author ijustlovemath

Instead of trying to add or replace nodes, you can simply get the document from the "updated" node.xml root note add solution.png

There is an errata here. The order of the xsi:schemaLocation value should be namespace, path, NOT path,namespace as the snippet shows. I've updated it in my code, but it's minor enough that I'll be keeping it in this post.

0 Kudos
Message 2 of 2
(2,732 Views)