Answers for "xml node js"

0

how to read xml element in xml2js

var xml2js = require('xml2js');
var xml = "<config><test>Hello</test><data>SomeData</data></config>";

var extractedData = "";
var parser = new xml2js.Parser();
parser.parseString(xml, function(err,result){
  //Extract the value from the data element
  extractedData = result['config']['data'];
  console.log(extractedData);
});
console.log("Note that you can't use value here if parseString is async; extractedData=", extractedData);
Posted by: Guest on September-18-2020
0

render XML in node

app.get('/sitemap.xml', function (req, res) {
  fs.readFile("./path/to/sitemap.xml", "utf-8", (err, data) => {
    if (err) {
      console.error(err);
      return
    }
    console.log(data);
    res.end(data) // Send Data
  });
});
Posted by: Guest on June-20-2021
0

get node inside node in of xml using java

for (int temp = 0; temp < NodeOzet.getLength(); temp++){
        Node nOzet = NodeOzet.item(temp);
        NodeList carList = eElement.getElementsByTagName("cars")
        String cars = "";
        for(int temp2 = 0; temp2 < carList.getLength(); temp2++){
             cars += ((Element)carList.item(temp2)).getAttribute("carname") + "\t";
        }
     }
Posted by: Guest on July-24-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language