xmlwrite – Control the order of attributes
Hi,
I wrote the following script to generate a XML-file…
xml_doc = com.mathworks.xml.XMLUtils.createDocument(‘Node’);
root = xml_doc.getDocumentElement();
tool_elem = xml_doc.createElement(‘Tool’);
tool_elem.setAttribute(‘name’,’me’);
tool_elem.setAttribute(‘defaultValue’,’1122′);
root.appendChild(tool_elem);
disp (xmlwrite(xml_doc));
… and I get the following result:
<?xml version="1.0" encoding="utf-8"?>
<Node>
<Tool defaultValue="1122" name="me"/>
</Node>
I know that the order is irrelevant from the point of the XML specification, but I would like to have the attribute "name" before "defaultValue" for readability.
Can I modify the order of the attributes?Hi,
I wrote the following script to generate a XML-file…
xml_doc = com.mathworks.xml.XMLUtils.createDocument(‘Node’);
root = xml_doc.getDocumentElement();
tool_elem = xml_doc.createElement(‘Tool’);
tool_elem.setAttribute(‘name’,’me’);
tool_elem.setAttribute(‘defaultValue’,’1122′);
root.appendChild(tool_elem);
disp (xmlwrite(xml_doc));
… and I get the following result:
<?xml version="1.0" encoding="utf-8"?>
<Node>
<Tool defaultValue="1122" name="me"/>
</Node>
I know that the order is irrelevant from the point of the XML specification, but I would like to have the attribute "name" before "defaultValue" for readability.
Can I modify the order of the attributes? Hi,
I wrote the following script to generate a XML-file…
xml_doc = com.mathworks.xml.XMLUtils.createDocument(‘Node’);
root = xml_doc.getDocumentElement();
tool_elem = xml_doc.createElement(‘Tool’);
tool_elem.setAttribute(‘name’,’me’);
tool_elem.setAttribute(‘defaultValue’,’1122′);
root.appendChild(tool_elem);
disp (xmlwrite(xml_doc));
… and I get the following result:
<?xml version="1.0" encoding="utf-8"?>
<Node>
<Tool defaultValue="1122" name="me"/>
</Node>
I know that the order is irrelevant from the point of the XML specification, but I would like to have the attribute "name" before "defaultValue" for readability.
Can I modify the order of the attributes? xmlwrite, attribute MATLAB Answers — New Questions