Copy link to clipboard
Copied
Hi Professionals
I can able to update the xml of the whole indesign document if there is any changes in the xml using script...
Here, my doubt is shall i update only the modified contents of xml without disturbing
the unmodified contents in the document.....
Thanks in Advance........
Regards,
-Parvathikannan.
To get any specific node & their attributes & CDATA, try like this or manipulate this:
var allCDATA = [];
var myXMLFile = File("C:/Users/r.sunil/Desktop/TestingCDATA/Test.xml");
myXMLFile.open('r');
var allElements = new XML(myXMLFile.read());
myXMLFile.close();
var allFeatureElements = allElements.xpath("//family_id");
for(var n = 0; n < allFeatureElements.length(); n++){
if(allFeatureElements.children().length() > 0){
getChildData(allFeatureElements);
}
}
//============
...
Copy link to clipboard
Copied
Hi Parvathikannan,
As per your post, I think your work flow is entirely XML based. As far as I can see it is better to import entire XML, because updating only changed XML structure will leave a margin for errors. To avoid that very small window for margin of error will be killed if you update entire XML.
But there is one more point if you update entire XML, you might have to put some more scripting if anything is getting changed(like paragraph style or character style) for those you need to do something, but after that no exception you will meet.
Best
Sunil
Copy link to clipboard
Copied
Dear Sunil Yadav,
You're right, My work flow is based on XML and i already have the functionality to update the entire XML with some scripting files. I can understand your suggestion but, our client requirement is to update only the modified xml contents in the InDesign documents without disturbing other contents. Is there is any way to do it?????
Regards,
ParvathiKannan.
Copy link to clipboard
Copied
There are always a way out.
If you are able enough to find out which xml element is modified(I am unsure how are you finding those). Then exactly those xml elements you can update in InDesign Files.
Sunil
Copy link to clipboard
Copied
Sunil, I'm Searching to find those modified contents, but i'm unable to do that.
If i'm able to get the family attribute id value then, there is a chance to get the elements value of the particular attribute it seems....
Is this possible?????????
Copy link to clipboard
Copied
I also tried but I couldn't.
If you find anyway to do that please do let me know. Track changes might be the option to find modified contents.
But for updating XML is concerned, I think you should update entire XML.
Copy link to clipboard
Copied
Dear Sunil,
Araised an doubt.......
I can able to fetch all the family_id value in XML....
By using that Family_id value shall i able to get the atrribute and the CDATA values that belong to that particular family_id. Is this possible????
Thanks,
ParvathiKannan.
Copy link to clipboard
Copied
Can you share some sample XML, then I might tell in better way.
Sunil
Copy link to clipboard
Copied
To get any specific node & their attributes & CDATA, try like this or manipulate this:
var allCDATA = [];
var myXMLFile = File("C:/Users/r.sunil/Desktop/TestingCDATA/Test.xml");
myXMLFile.open('r');
var allElements = new XML(myXMLFile.read());
myXMLFile.close();
var allFeatureElements = allElements.xpath("//family_id");
for(var n = 0; n < allFeatureElements.length(); n++){
if(allFeatureElements.children().length() > 0){
getChildData(allFeatureElements);
}
}
//===================
function getChildData(nodeData){
for(var c = 0; c < nodeData.children().length(); c++){
if(nodeData.children()[c].toXMLString().toString().indexOf("<![CDATA[") == 0){
alert(nodeData.children()[c].toString());
allCDATA.push(nodeData.children()[c].toString());
}
if(nodeData.children()[c].children().length() > 0){
getChildData(nodeData.children()[c]);
}
}
}
alert(allCDATA);
Best
Sunil
Copy link to clipboard
Copied
It is easily possible to update XML even node by node.
Best
Sunil
Copy link to clipboard
Copied
Dear Sunil,
I've attached the screenshot of my XML....
In the below XML each and every family has their own attribute and the element values. Now, by using family_id how do i get all the attribute node values....
Another thing is in the XML you can see the specs_type which has two atrribute titles and description, I need to get the CDATA values individually. But, now i'm getting both the title and description CDATA values together. How to get the CDATA values seprately????
Thanks,
ParvathiKannan.
Copy link to clipboard
Copied
And same way i know that node by node update process is possible...
If i need to update an single node of an XML is possible?????
Thanks,
-ParvathiKannan.
Copy link to clipboard
Copied
I've attached the sample XML in the below link. Kindly check it.
https://www.dropbox.com/s/pbsrqs9rhjrxwxb/Sample.xml?dl=0
-ParvathiKannan.
Copy link to clipboard
Copied
Updating a single node is also easily posible.
Now here we should understand: Whenever you need to store values separately, you should think on it & you can work on it.
I showed you a way to fetch all CDATA & already you know how to differentiate between differrent different node/s. SO accordingly you can create code logic wise.
Best
Sunil
Copy link to clipboard
Copied
Yeah! I got it sunil. Thankyou!
Thanks,
ParvathiKannan.