第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

關(guān)于handle中重寫startElement()方法中的參數(shù)問題

startElement(String uri, String localName, String qName,

Attributes attributes)中的參數(shù)在哪里傳入handle對(duì)象的呀?主函數(shù)里新建了一個(gè)handle對(duì)象,也沒傳參數(shù)呀?尤其這個(gè)localName參數(shù),都沒有見到呀,或者是parse()函數(shù)傳來的?


正在回答

3 回答

我感覺這個(gè)startElement方法應(yīng)該是JAVA官方類的源代碼中的方法,只有用法。當(dāng)你主函數(shù)調(diào)用parse(uri,dh)時(shí),parse方法就已經(jīng)把xml文件進(jìn)行解析,并且獲取了你問題里的參數(shù),這都是官方類的操作,我們看不到的。

1 回復(fù) 有任何疑惑可以回復(fù)我~
#1

0110號(hào)建筑師 提問者

非常感謝!
2017-06-05 回復(fù) 有任何疑惑可以回復(fù)我~

請(qǐng)注意看參數(shù)

0 回復(fù) 有任何疑惑可以回復(fù)我~

SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();

SAXParser saxParser = saxParserFactory.newSAXParser();

SaxParserHandler saxParserHandler = new SaxParserHandler();

saxParser.parse("books.xml", saxParserHandler);

//parse()?

public void parse(String uri, DefaultHandler dh)

? ? ? ? throws SAXException, IOException {

? ? ? ? if (uri == null) {

? ? ? ? ? ? throw new IllegalArgumentException("uri cannot be null");

? ? ? ? }


? ? ? ? InputSource input = new InputSource(uri);

? ? ? ? this.parse(input, dh);//------------執(zhí)行到此處

? ? }


public void parse(InputSource is, DefaultHandler dh)

? ? ? ? throws SAXException, IOException {

? ? ? ? if (is == null) {

? ? ? ? ? ? throw new IllegalArgumentException("InputSource cannot be null");

? ? ? ? }


? ? ? ? XMLReader reader = this.getXMLReader();

? ? ? ? if (dh != null) {

? ? ? ? ? ? reader.setContentHandler(dh);

? ? ? ? ? ? reader.setEntityResolver(dh);

? ? ? ? ? ? reader.setErrorHandler(dh);

? ? ? ? ? ? reader.setDTDHandler(dh);

? ? ? ? }

? ? ? ? reader.parse(is);//----------

? ? }


?public void parse (InputSource input)

? ? ? ? throws IOException, SAXException;

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

void org.xml.sax.XMLReader





?/**

? ? ?* Receive notification of the start of an element.

? ? ?*

? ? ?* <p>By default, do nothing.? Application writers may override this

? ? ?* method in a subclass to take specific actions at the start of

? ? ?* each element (such as allocating a new tree node or writing

? ? ?* output to a file).</p>

? ? ?*

? ? ?* @param uri The Namespace URI, or the empty string if the

? ? ?*? ? ? ? element has no Namespace URI or if Namespace

? ? ?*? ? ? ? processing is not being performed.

? ? ?* @param localName The local name (without prefix), or the

? ? ?*? ? ? ? empty string if Namespace processing is not being

? ? ?*? ? ? ? performed.

? ? ?* @param qName The qualified name (with prefix), or the

? ? ?*? ? ? ? empty string if qualified names are not available.

? ? ?* @param attributes The attributes attached to the element.? If

? ? ?*? ? ? ? there are no attributes, it shall be an empty

? ? ?*? ? ? ? Attributes object.

? ? ?* @exception org.xml.sax.SAXException Any SAX exception, possibly

? ? ?*? ? ? ? ? ? wrapping another exception.

? ? ?* @see org.xml.sax.ContentHandler#startElement

? ? ?*/

? ? public void startElement (String uri, String localName,

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? String qName, Attributes attributes)

? ? ? ? throws SAXException

? ? {

? ? ? ? // no op

? ? }


0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

關(guān)于handle中重寫startElement()方法中的參數(shù)問題

我要回答 關(guān)注問題
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)