JavaScript read a value from .config file using javascript read value from dictionary c#,read value from json,read

I tried to get a value from a file with .config extension using the below code, but i am not able to get it...........

if i change the file extesion from .config to .xml the its working fine(I am able to acheive the expected result)

//-----------------------------------------------------

 xmlDoc = new ActiveXObject('Microsoft.XMLDOM');
        xmlDoc.async = false;
        var b = xmlDoc.load("books.config");//load a file
document.write("<br>" + xmlDoc.length);
        document.write("<br>" + xmlDoc.getElementsByTagName("book").length);
        for (j = 0; j < xmlDoc.getElementsByTagName("book").length; j++) {
            // x = xml.getElementsByTagName("FeatureToggles")[j].attributes;
            x = xmlDoc.getElementsByTagName("book")[j].attributes;
            y = x.getNamedItem("category");
            document.write("<br>" +"category = "+ x.getNamedItem("category").nodeValue);
            document.write("<br>" + x.length);
            if (x.getNamedItem("cover")!=null && x.getNamedItem("cover").nodeValue == "paperback") {
                document.write("Found");
            }
        }

//-----------------------------------------------------------------------------

Sample xml/config:

<bookstore>
<book category="cooking">
<title lang="en">Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
</book>
<book category="children">
<title lang="en">Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
<book category="web">
<title lang="en">XQuery Kick Start</title>
<author>James McGovern</author>
<author>Per Bothner</author>
<author>Kurt Cagle</author>
<author>James Linn</author>
<author>Vaidyanathan Nagarajan</author>
<year>2003</year>
<price>49.99</price>
</book>
<book category="web" cover="paperback">
<title lang="en">Learning XML</title>
<author>Erik T. Ray</author>
<year>2003</year>
<price>39.95</price>
</book>
</bookstore>
Answer:1

This probably happens because the load method requires an XML file and your browser doesn't know that the .config extension is actually XML. If you were serving this file from a server, you could add the proper headers to tell the browser that the .config file is XML. Without the headers, your browser has to try and figure it out (this process is documented here: https://msdn.microsoft.com/en-us/library/ms775148%28v=vs.85%29.aspx). If this hypothesis is correct, the variable b that you are setting in your question (the return value of the load method) should be false.

xmlSource: A string containing a URL that specifies the location of the XML file.

https://msdn.microsoft.com/en-us/library/ms762722%28v=vs.85%29.aspx

To fix this, you can serve the file with the proper headers (the best approach if this is an app others will use), tell your browser to handle .config files as XML (probably not a good idea) or just use the .xml extension since this seems to be mapped by the browser automatically.

Answer:2

I am writting a firefox os application and I found a strange problem. I have two web activities (open a link on a projects tab and sending an e-mail on the users tab ) what are work correctly under ...

I am writting a firefox os application and I found a strange problem. I have two web activities (open a link on a projects tab and sending an e-mail on the users tab ) what are work correctly under ...

I want to build a JavaScript regular expression to match all words starting with "ad" or "ae", or all words that contain "-ad" and "-ae". This is what I've tried: var regex_string = "^[ad|ae]|-[ad|...

I want to build a JavaScript regular expression to match all words starting with "ad" or "ae", or all words that contain "-ad" and "-ae". This is what I've tried: var regex_string = "^[ad|ae]|-[ad|...

  1. regular expressions javascript cheat sheet
  2. regular expressions javascript tutorial
  3. regular expressions javascript examples
  4. regular expressions javascript
  5. regular expressions javascript online
  6. regular expressions javascript w3schools
  7. regular expressions javascript mdn
  8. regular expressions javascript pdf
  9. regular expressions javascript test
  10. regular expressions js
  11. regular expression javascript tester
  12. regular expression javascript email
  13. regular expression javascript validation
  14. regular expression javascript match
  15. regular expression javascript replace
  16. regular expression javascript generator
  17. regular expression javascript only numbers
  18. regular expression javascript special characters
  19. regular expression javascript phone number
  20. regular expression javascript email validation

I have an controller which is simply watching a 'name' property and prints its new and old values on any change. function Ctrl($scope) { $scope.$watch('name', function(newValue, oldValue) { ...

I have an controller which is simply watching a 'name' property and prints its new and old values on any change. function Ctrl($scope) { $scope.$watch('name', function(newValue, oldValue) { ...

I am trying to replace all occurences of 'S' (capital S) with '.sss' : For example the following line doesn't even contain a capital S in it and it still replaces a lot : "MM/dd/yyyy EEEE hh:mm aa"....

I am trying to replace all occurences of 'S' (capital S) with '.sss' : For example the following line doesn't even contain a capital S in it and it still replaces a lot : "MM/dd/yyyy EEEE hh:mm aa"....