Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Fetching XML attribute values

New Here ,
Oct 19, 2020 Oct 19, 2020

Copy link to clipboard

Copied

Hi Experts,

 

I need to fetch the xml content values using a script, i have attached the image below, in that the content values within CDATA need to be dispalyed. How do i do this???????????

 

ParvathiKannan_0-1603099108233.png

Thanks In Advance

 

Regards,

ParvathiKannan.

TOPICS
How to, Import and export, Scripting

Views

199

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Adobe Community Professional , Oct 19, 2020 Oct 19, 2020
Fetching CDATA has already been answered on above mentioned thread. 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("//feature"); for(var n = 0; n < allFeatureElements.length(); n++){ if(allFeatureElements.children().length() > 0){ getChildData(allFeatureElements); } } //=================== function getC...

Likes

Translate

Translate
Adobe Community Professional ,
Oct 19, 2020 Oct 19, 2020

Copy link to clipboard

Copied

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Oct 19, 2020 Oct 19, 2020

Copy link to clipboard

Copied

Fetching CDATA has already been answered on above mentioned thread.

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("//feature");
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

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 26, 2020 Oct 26, 2020

Copy link to clipboard

Copied

LATEST

Dear Sunil,

 

ThankYou!

I've made some changes in the above code and now i'm able to reach what i want....

 

Thanks,

ParvathiKannan.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines