CS174
Chris Pollett
May 3, 2021
<patient type="out of state"> <![CDATA[This is data that will not be parsed by the XML parser even if it has tags in it like this: <tag>]]> <name><first>John</first><last>Smith</last></name> <insurerID>&kaiser;</insurerID> </patient>
<!ELEMENT element_name (list of names of child elements) SYSTEM Location NDATA NotationName >
<!ELEMENT memo (from, to, date) > ---- SYSTEM and NDATA don't have to used <!ELEMENT dept_script SYSTEM "dept.php" NDATA "php" > <!NOTATION php SYSTEM "/usr/bin/php" > <!ELEMENT person(parent+, age, spouse?, sibling*) > ---- + is one or more, ? is optional, and * is 0 or more <!ELEMENT element_name (#PCDATA) > ---- pcdata = parsable character data can also use EMPTY for no sub-tags or character data or ANY if you want to allow everything
<!ATTLIST element_name attribute_name_1 attribute_type [default_value] ... attribute_name_n attribute_type [default_value] >
<!ATTLIST airplane places CDATA "4"> <!ATTLIST airplane engine_type CDATA #REQUIRED> ---- must have the field <!ATTLIST airplane price CDATA #IMPLIED> ---- no default value is given <!ATTLIST airplane manufacturer CDATA #FIXED "cessna"> --- all instances must have the same value
<!ATTLIST img src CDATA #REQUIRED width CDATA #REQUIRED height CDATA #REQUIRED alt CDATA #IMPLIED >
<!ATTLIST horizontal_rule alignment (left|center|right) #IMPLIED >
<!ENTITY [%] entity_name "entity value" >% is used when it is a parameter entity
<!ENTITY cp "Chris Pollett" > <!ENTITY cool_pic SYSTEM "/usr/local/cool_pic.jpg">
<?xml version = "1.0" encoding ="utf-8" ?> <!-- planes_for_sale.dtd --> <!ELEMENT planes_for_sale (ad+) > <!ELEMENT ad (year, make, model, color, price?, seller) > <!ELEMENT year (#PCDATA)> <!ELEMENT make (#PCDATA)> <!ELEMENT model (#PCDATA)> <!ELEMENT color (#PCDATA)> <!ELEMENT price (#PCDATA)> <!ELEMENT seller (#PCDATA)> <!ATTLIST seller license CDATA #REQUIRED > <!ENTITY c "cessna" >
<?xml version="1.0" encoding="utf-8" ?> <!DOCTYPE planes_for_sale.dtd [ <!--DTD for planes_for_sale-->]> <!-- The planes_for_sale document -->
<!DOCTYPE planes_for_sale SYSTEM "planes_for_sale.dtd" >
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE planes_for_sale SYSTEM "planes_for_sale.dtd" > <planes_for_sale> <ad> <year>1960</year> <make>&c;</make> <model>150</model> <color>white</color> <seller license="12345678">Duran Duran</seller> </ad> <ad> <year>1945</year> <make>Douglas Aircraft Company</make> <model>DC-3</model> <color>red</color> <seller license="ABCDEFG">Gyro Gearloose</seller> </ad> </planes_for_sale>
<div xmlns="http://www.w3.org/1999/xhtml" xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML" >
plane {display:block; border 3px;}
<?xml-stylesheet type="text/css" href="mystyles.css" ?>
request = new XMLHttpRequest();
request.setRequestHeader("name", "value");
request.open(theHTTPmethod, theURL, theAsync flag) or request.open(theHTTPmethod, theURL, theAsync flag, username, password)
request.open("GET", "test-news.html", true); request.onreadystatechange = function() { switch(request.readyState) { case 0:// handle uninitialized case case 1: // handle open but no send case case 2: // handle send but no response case case 3: // handle response is being downloaded case case 4: // handle response has completed being downloaded case } }
document.getElementById("myDivTag").innerHTML = request.responseText; //or we could do... myDiv = document.getElementById("myDivTag") if(myDiv.firstChild) { myDiv.removeChild(myDiv.firstChild); } myDiv.appendChild(document.createTextNode(request.responseText));
request = new XMLHttpRequest(); request.onreadystatechange = function() { switch(request.readyState) { case 4: document.getElementById("test-news").innerHTML = request.responseText; break; } } request.open("GET", "test_news.html", true); request.send();
request.send(null);Note: send's argument can be used if using POST method to send the posted data
my_object = JSON.parse(request.responseText);
Which of the following statements is true?
http://www.yioop.com/s/news?f=rss&limit=20&num=30
url/my_obj/method1?arg_1_for_method1=value_1& arg_2_for_method1=value_2... url/my_obj/method2?arg_1_for_method2=value_1& arg_2_for_method2=value_2... ...
12.3 -- an example Number "hi there" -- an example String true -- an example Boolean, other possibility false
[1, 4, 9]
{"bob": 29, "sally" : 35}
myObj = eval( "(" + data + ")" );