Search completed in 0.96 seconds.
nsIDOMParser
note: if you're a web developer, please refer to the
domparser documentation instead.
... creating a
domparser to create a
domparser object from a web page or a chrome script running in a window, simply use new
domparser().
... when you create a
domparser from a privileged script, you can pass parameters to the constructor, more on that below.
...And 7 more matches
DOMParser - Web APIs
the
domparser interface provides the ability to parse xml or html source code from a string into a dom document.
... syntax let
domparser = new
domparser() methods
domparser.parsefromstring() syntax let doc =
domparser.parsefromstring(string, mimetype) return either document or xmldocument depending on the mimetype argument.
...type doc.constructor text/html document text/xml xmldocument application/xml xmldocument application/xhtml+xml xmldocument image/svg+xml xmldocument examples parsing xml once you have created a parser object, you can parse xml from a string using the parsefromstring() method: let parser = new
domparser() let doc = parser.parsefromstring(stringcontainingxmlsource, "application/xml") error handling note that if the parsing process fails, the
domparser does not throw an exception, but instead returns an error document: <parsererror xmlns="http://www.mozilla.org/newlayout/xml/parsererror.xml"> (error description) <sourcetext>(a snippet of the source xml)</sourcetext> </parsererror> the pa...
...And 6 more matches
DOMParser() - Web APIs
the
domparser() constructor creates a new
domparser object.
... syntax var parser = new
domparser(); parameters none.
... return value a new
domparser object.
XML Extras
feature status feature status xmlserializer available xmlhttprequest available
domparser (string and stream input source) available web services with soap and wsdl no longer available from gecko 1.9/firefox 3.
...the "workaround" is to use
domparser object's parsefromstring() method to create a document from string, and pass the temporary document into send().
...
domparser creation not available new
domparser() xmlserializer creation not available new xmlserializer() minimal documentation for the components listed above can be found using mozilla documentation generated by doxygen.
... nsidomserializer (currently, the javascript constructor is xmlserializer()) nsi
domparser (currently, the javascript constructor is
domparser()) nsixmlhttprequest please see the xml linking and pointing section in xml in mozilla document for fixptr and xpointer documentation.
Using XML Data Islands in Mozilla - Archive of obsolete content
la.org/purchaseorderml"> <lineitem> <name>line item 1</name> <price>1.25</price> </lineitem> <lineitem> <name>line item 2</name> <price>2.48</price> </lineitem> </purchaseorder> </script> the xml source text can then be retrieved like this: var ordersource = document.getelementbyid("purchase-order").textcontent; the xml source text can be parsed into a dom tree using the
domparser api: var parser = new
domparser(); var doc = parser.parsefromstring(ordersource, "application/xml"); the html5 data block-based way shown here works in firefox, opera, webkit-based browsers such as chrome and safari, and ie9 while ie's xml data islands work only in ie.
...pe="application/xml"> <purchaseorder xmlns="http://example.mozilla.org/purchaseorderml"> <lineitem> <name>line item 1</name> <price>1.25</price> </lineitem> <lineitem> <name>line item 2</name> <price>2.48</price> </lineitem> </purchaseorder> </script> <script> function rundemo() { var ordersource = document.getelementbyid("purchase-order").textcontent; var parser = new
domparser(); var doc = parser.parsefromstring(ordersource, "application/xml"); var lineitems = doc.getelementsbytagnamens("http://example.mozilla.org/purchaseorderml", "lineitem"); var firstprice = lineitems[0].getelementsbytagnamens("http://example.mozilla.org/purchaseorderml", "price")[0].textcontent; document.body.textcontent = "the purchase order contains " + lineitems.length + " line items.
... the price of the first line item is " + firstprice + "."; } </script> </head> <body onload="rundemo()";> demo did not run </body> </html> the xml source text can be parsed into a dom tree using the
domparser api: var parser = new
domparser(); var doc = parser.parsefromstring(ordersource, "application/xml"); the html5 data block-based way shown here works in firefox, opera, webkit-based browsers such as chrome and safari, and ie9 while ie's xml data islands work only in ie.
Connecting to Remote Content - Archive of obsolete content
let
domparser = components.classes["@mozilla.org/xmlextras/
domparser;1"] .createinstance(components.interfaces.nsi
domparser); let filestream = components.classes["@mozilla.org/network/file-input-stream;1"] .createinstance(components.interfaces.nsifileinputstream); let xsltprocessor = components.classes["@mozilla.org/document-transformer;1?type=xslt"] .createinsta...
...nce(components.interfaces.nsixsltprocessor); let xsldocument; filestream.init(somexslfile, -1, 0x01, 0444); // read only // parse from the xslt stylesheet file stream xsldocument =
domparser.parsefromstream( filestream, null, filestream.available(), "text/xml"); // import the xslt stylesheet to the xslt processor xsltprocessor.importstylesheet(xsldocument); finally, you can either use nsixsltprocessor.transformtodocument() or nsixsltprocessor.transformtofragment() methods to transform the xml document.
Microsummary topics - Archive of obsolete content
"http://www.w3.org/1999/xsl/transform" version="1.0"> \ <output method="text"/> \ <template match="/"> \ <value-of select="id(\'download-count\')"/> \ <text> fx downloads</text> \ </template> \ </transform> \ </template> \ <pages> <include>http://(www\.)?spreadfirefox\.com/(index\.php)?</include> </pages> </generator> \ '; var
domparser = components.classes["@mozilla.org/xmlextras/
domparser;1"].
... createinstance(components.interfaces.nsi
domparser); var generatordoc =
domparser.parsefromstring(generatortext, "text/xml"); var microsummaryservice = components.classes["@mozilla.org/microsummary/service;1"].
Migrate apps from Internet Explorer to Mozilla - Archive of obsolete content
mozilla uses the
domparser object, which takes the serialized string and creates an xml document out of it.
...the following code shows you how: var xmlstring = "<xml id=\"xmldataisland\"><foo>bar</foo></xml>"; var mydocument; if (window.
domparser) { // this browser appears to support
domparser var parser = new
domparser(); mydocument = parser.parsefromstring(xmlstring, "text/xml"); } else if (window.activexobject){ // internet explorer, create a new xml document using activex // and use loadxml as a dom parser.
JS-Engine FAQ - Archive of obsolete content
check the jsval macros at the top of js/src/jsapi.h can an embedded spidermonkey js engine use
domparser extension of mozilla?
...
domparser is not part of js but part of mozilla browser which makes it available to script in the browser using xpconnect.
XForms Custom Controls Examples - Archive of obsolete content
urn true; </body> </method> </implementation> </binding> output showing xhtml <binding id="output-xhtml" extends="chrome://xforms/content/xforms-xhtml.xml#xformswidget-output"> <content> <children includes="label"/> <xhtml:div class="xf-value" anonid="content"></xhtml:div> <children/> </content> <implementation implements="nsixformsuiwidget"> <field name="_
domparser">null</field> <property name="
domparser" readonly="true"> <getter> if (!this._
domparser) this._
domparser = new
domparser(); return this._
domparser; </getter> </property> <method name="refresh"> <body> // get new value, parse, and import it.
... var val = this.stringvalue; var newdom = this.
domparser.parsefromstring(val, "text/xml"); var impnode = document.importnode(newdom.firstchild, true); // get content node, clean it, and update it var content = document.getanonymouselementbyattribute(this, "anonid", "content"); if (content.firstchild) { content.removechild(content.firstchild); } content.appendchild(impnode); return true; </body> </method> </implementation> </binding> ...
Index
511 nsi
domparser to create a
domparser object from a web page or a chrome script running in a window, simply use new
domparser().
... when you create a
domparser from a privileged script, you can pass parameters to the constructor, more on that below.
Index - Web APIs
726
domparser api, dom, dom parsing, document, html, htmldocument, makebrowseragnostic, needsmarkupwork, parsing, reference, svg, xml, xmldocument the
domparser interface provides the ability to parse xml or html source code from a string into a dom document.
... 727
domparser() api, constructor, dom parsing, parsing, reference the
domparser() constructor creates a new
domparser object.
Window - Web APIs
domparser domparser can parse xml or html source stored in a string into a dom document.
...
domparser is specified in dom parsing and serialization.
Parsing and serializing XML - Developer guides
domparser constructs a dom tree by parsing a string containing xml, returning a xmldocument or document as appropriate based on the input data.
... parsing strings into dom trees this example converts an xml fragment in a string into a dom tree using a
domparser: var smystring = '<a id="a"><b id="b">hey!</b></a>'; var oparser = new
domparser(); var odom = oparser.parsefromstring(smystring, "application/xml"); // print the name of the root element or error message console.log(odom.documentelement.nodename == "parsererror" ?
Index - Archive of obsolete content
189 html to dom code snippets, dom, guide, html, intermediate, needsupdate although you can now natively parse html using
domparser and xmlhttprequest, this is a new feature that is not yet supported by all browsers in use in the wild.
jspage - Archive of obsolete content
s.url});return this;}});request.html=new class({extends:request,options:{update:false,append:false,evalscripts:true,filter:false},processhtml:function(c){var b=c.match(/<body[^>]*>([\s\s]*?)<\/body>/i); c=(b)?b[1]:c;var a=new element("div");return $try(function(){var d="<root>"+c+"</root>",g;if(browser.engine.trident){g=new activexobject("microsoft.xmldom"); g.async=false;g.loadxml(d);}else{g=new
domparser().parsefromstring(d,"text/xml");}d=g.getelementsbytagname("root")[0];if(!d){return null;}for(var f=0,e=d.childnodes.length; f<e;f++){var h=element.clone(d.childnodes[f],true,true);if(h){a.grab(h);}}return a;})||a.set("html",c);},success:function(d){var c=this.options,b=this.response; b.html=d.stripscripts(function(e){b.javascript=e;});var a=this.processhtml(b.html);b.tree=a.childnodes;b.elements=...
XML in Mozilla - Archive of obsolete content
orted xml w3c recommendations specification or technology documentation mozilla project xslt w3c recommendation xslt xpath w3c recommendation xslt xmlhttprequest w3c recommendation xml extras request api (no longer supported) mozilla add-on sdk
domparser and xmlserializer mozilla xml extras sax sax soap (no longer supported) w3c note web services xml-rpc (no longer supported) userland software xml-rpc rdf w3c recommendations rdf svg w3c recommendation svg animation (smil) ...
What XULRunner Provides - Archive of obsolete content
the following features are either already implemented or planned: gecko features xpcom networking gecko rendering engine dom editing and transaction support (no ui) cryptography xbl (xbl2 planned) xul svg xslt xml extras (xmlhttprequest,
domparser, etc.) web services (soap) auto-update support (not yet complete) type ahead find toolbar history implementation (the places implementation in the 1.9 cycle) accessibility support ipc services for communication between gecko-based apps (not yet complete) storage/sqlite interfaces user interface features the following user interface is supplied by xulrunner, and may be overridden by...
Writing JavaScript for XHTML - Archive of obsolete content
for example: var string = '<div xmlns="http://www.w3.org/999/xhtml"><h1>hello world!</h1></div>'; var parser = new
domparser(); var documentfragment = parser.parsefromstring(string, "text/xml"); body.appendchild(documentfragment); // assuming 'body' is the body element but be aware that if your string is not well-formed xml (e.g., you have an & where it should not be), then this method will crash, leaving you with a parser error.
XPCOM Interface Reference
geopositionoptionsnsidomglobalpropertyinitializernsidomhtmlaudioelementnsidomhtmlformelementnsidomhtmlmediaelementnsidomhtmlsourceelementnsidomhtmltimerangesnsidomjswindownsidommousescrolleventnsidommoznetworkstatsnsidommoznetworkstatsdatansidommoznetworkstatsmanagernsidommoztoucheventnsidomnshtmldocumentnsidomnavigatordesktopnotificationnsidomnodensidomofflineresourcelistnsidomorientationeventnsi
domparsernsidomprogresseventnsidomserializernsidomsimplegestureeventnsidomstoragensidomstorage2nsidomstorageeventobsoletensidomstorageitemnsidomstoragelistnsidomstoragemanagernsidomstoragewindownsidomuserdatahandlernsidomwindownsidomwindow2nsidomwindowinternalnsidomwindowutilsnsidomxpathevaluatornsidomxpathexceptionnsidomxpathexpressionnsidomxpathresultnsidomxulcontrolelementnsidomxulelementnsidomxullabele...
Document.createCDATASection() - Web APIs
example var docu = new
domparser().parsefromstring('<xml></xml>', 'application/xml') var cdata = docu.createcdatasection('some <cdata> data & then some'); docu.getelementsbytagname('xml')[0].appendchild(cdata); alert(new xmlserializer().serializetostring(docu)); // displays: <xml><![cdata[some <cdata> data & then some]]></xml> notes this will only work with xml, not html documents (as html documents do not support cdata sections); attempting it on an html document will throw not_supported_err.
Document.createComment() - Web APIs
example var docu = new
domparser().parsefromstring('<xml></xml>', 'application/xml'); var comment = docu.createcomment('this is a not-so-secret comment in your document'); docu.getelementsbytagname('xml')[0].appendchild(comment); alert(new xmlserializer().serializetostring(docu)); // displays: <xml><!--this is a not-so-secret comment in your document--></xml> specifications specification status comment domthe definition of 'document.createcomment' in that specification.
Document.createProcessingInstruction() - Web APIs
example var doc = new
domparser().parsefromstring('<foo />', 'application/xml'); var pi = doc.createprocessinginstruction('xml-stylesheet', 'href="mycss.css" type="text/css"'); doc.insertbefore(pi, doc.firstchild); console.log(new xmlserializer().serializetostring(doc)); // displays: <?xml-stylesheet href="mycss.css" type="text/css"?><foo/> specifications specification status comment domthe defi...
Web APIs
nstraindomstring constraindouble constrainulong contentindex contentindexevent convolvernode countqueuingstrategy crashreportbody credential credentialscontainer crypto cryptokey cryptokeypair customelementregistry customevent d domconfiguration domerror domexception domhighrestimestamp domimplementation domimplementationlist domlocator dommatrix dommatrixreadonly domobject
domparser dompoint dompointinit dompointreadonly domquad domrect domrectreadonly domstring domstringlist domstringmap domtimestamp domtokenlist domuserdata datatransfer datatransferitem datatransferitemlist dedicatedworkerglobalscope delaynode deprecationreportbody devicelightevent devicemotionevent devicemotioneventacceleration devicemotioneventrotationrate deviceorientationevent devicepro...