Been handed a project that is tied with Libxml2
Issue is that there are existing XMLs that have become outdated and need to have additional fields added to support new hardware. Those field are expected to be added in each "block/group" However, the blocks/groups are not delineated but grouped by the first 6 characters label and 2 digit number itself
Sample of the XML being used.
I want to insert an XML line within each block as shown below
Bolding is my doing for emphasis.
If I use the xmlNewChild the fields are appended to the end of the file.
Functionally, this will work, but cosmetically, it is very confusing to anyone that views the XML file.
so if I use the xmlAddNextSibling the first insertion happens,
but the XML output gets truncated as shown
what am I missing to get the insertion to happen and avoid the truncation.
There is only one parent/root
If I use the Sibling vs Child will that help?
I am unable to locate information that explains the difference/use of the two.
Issue is that there are existing XMLs that have become outdated and need to have additional fields added to support new hardware. Those field are expected to be added in each "block/group" However, the blocks/groups are not delineated but grouped by the first 6 characters label and 2 digit number itself
Sample of the XML being used.
Code:
<aspusystem devicetype="ASPU" vercreated="1.0.1.0" version="100" verupdated="1.0.1.0">
<Alert1Interrupting>0</Alert1Interrupting>
<Alert1InterruptibleType>0</Alert1InterruptibleType>
<Alert2Interrupting>0</Alert2Interrupting>
<Alert2InterruptibleType>0</Alert2InterruptibleType>
...
<Alert#Interrupting>0</Alert#Interrupting>
<Alert#InterruptibleType>0</Alert#InterruptibleType>
</aspusystem
I want to insert an XML line within each block as shown below
Bolding is my doing for emphasis.
Code:
<aspusystem devicetype="ASPU" vercreated="1.0.1.0" version="100" verupdated="1.0.1.0">
<Alert1Interrupting>0</Alert1Interrupting>
[COLOR="red"][B]<Alert1Immediate>0</Alert1Immediate>[/B][/COLOR]
<Alert1InterruptibleType>0</Alert1InterruptibleType>
<Alert2Interrupting>0</Alert2Interrupting>
[COLOR="red"][B]<Alert2Immediate>0</Alert2Immediate>[/B][/COLOR]
<Alert2InterruptibleType>0</Alert2InterruptibleType>
...
<Alert#Interrupting>0</Alert#Interrupting>
[COLOR="Red"][B]<Alert#Immediate>0</Alert#Immediate>[/B][/COLOR]
<Alert#InterruptibleType>0</Alert#InterruptibleType>
</aspusystem>
If I use the xmlNewChild the fields are appended to the end of the file.
Functionally, this will work, but cosmetically, it is very confusing to anyone that views the XML file.
Code:
xmlNodePtr newNode = NULL;
newNode = xmlNewChild(RootNode,
NULL,
xSTRCHR(sAlertField),
xSTRCHR(sContent));
so if I use the xmlAddNextSibling the first insertion happens,
Code:
xmlNodePtr nodeRef = GetNode(sInsertionReference);
xmlNodePtr newNode = NULL;
newNode = xmlNewChild(RootNode,
NULL,
xSTRCHR(sAlertField),
xSTRCHR(sContent));
newNode = xmlAddNextSibling (nodeRef,newNode);
Code:
<aspusystem devicetype="ASPU" vercreated="1.0.1.0" version="100" verupdated="1.0.1.0">
<Alert1Interrupting>0</Alert1Interrupting>
[COLOR="red"][B]<Alert1Immediate>0</Alert1Immediate>[/B][/COLOR]
</aspusystem>
what am I missing to get the insertion to happen and avoid the truncation.
There is only one parent/root
If I use the Sibling vs Child will that help?
I am unable to locate information that explains the difference/use of the two.