• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

345

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

Advocate , 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
...

Votes

Translate

Translate
Community Expert ,
Oct 19, 2020 Oct 19, 2020

Copy link to clipboard

Copied

Votes

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
Advocate ,
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

Votes

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.

Votes

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