Namespace
Usage
The XmlStreamReader class is similar to the XMLStreamReader utility class from StAX (Streaming API for XML). StAX is an API to read and write XML documents, originating from the Java programming language community.
XmlStreamReader Constructors
The following are constructors for XmlStreamReader.
XmlStreamReader(xmlInput)
Signature
public XmlStreamReader(String xmlInput)
Parameters
-
xmlInput:
Type: String
The XML string input.
XmlStreamReader Methods
The following are methods for XmlStreamReader. All are instance methods.
getAttributeCount()
Signature
public Integer getAttributeCount()
Return Value
Type: Integer
Usage
This method is only valid on a start element or attribute XML events. The count for the number of attributes for an attribute XML event starts with zero.
getAttributeLocalName(index)
getAttributeNamespace(index)
Signature
public String getAttributeNamespace(Integer index)
Parameters
-
index:
Type: Integer
Return Value
Type: String
Usage
If no namespace is specified, null is returned. This method is only valid with start element or attribute XML events.
getAttributeValue(namespaceUri, localName)
Signature
public String getAttributeValue(String namespaceUri, String localName)
Return Value
Type: String
Usage
Returns null if the value is not found. You must specify a value for localName. This method is only valid with start element or attribute XML events.
getEventType()
Signature
public System.XmlTag getEventType()
Return Value
Type: System.XmlTag
getLocalName()
Signature
public String getLocalName()
Return Value
Type: String
Usage
For start element or end element XML events, it returns the local name of the current element. For the entity reference XML event, it returns the entity name. The current XML event must be start element, end element, or entity reference.
getLocation()
Signature
public String getLocation()
Return Value
Type: String
Usage
If the location is unknown, returns -1. The location information is only valid until the next method is called.
getNamespace()
Signature
public String getNamespace()
Return Value
Type: String
Usage
Returns null if the XML event does not have a prefix.
getNamespaceCount()
Signature
public Integer getNamespaceCount()
Return Value
Type: Integer
getNamespacePrefix(index)
Signature
public String getNamespacePrefix(Integer index)
Parameters
-
index:
Type: Integer
Return Value
Type: String
Usage
Returns null if this is the default namespace declaration. This method is only valid on a start element, end element, or namespace XML event.
getPIData()
Signature
public String getPIData()
Return Value
Type: String
getPITarget()
Signature
public String getPITarget()
Return Value
Type: String
getPrefix()
Signature
public String getPrefix()
Return Value
Type: String
getText()
Signature
public String getText()
Return Value
Type: String
Usage
The valid values for the different events are:
- The string value of a character XML event
- The string value of a comment
- The replacement value for an entity reference. For example, assume getText reads the following XML
snippet:The getText method returns Salesforce for Dummies, not &Title.
<!ENTITY Title "Salesforce For Dummies" > ]> <moo a="b">Name &Title;</moo>'; - The string value of a CDATA section
- The string value for a space XML event
- The string value of the internal subset of the DTD
getVersion()
Signature
public String getVersion()
Return Value
Type: String
hasName()
Signature
public Boolean hasName()
Return Value
Type: Boolean
Usage
This method is only valid for start element and stop element XML events.
hasNext()
Signature
public Boolean hasNext()
Return Value
Type: Boolean
Usage
This method returns false if the current XML event is end document.
hasText()
Signature
public Boolean hasText()
Return Value
Type: Boolean
Usage
The following XML events have text: characters, entity reference, comment and space.
isCharacters()
Signature
public Boolean isCharacters()
Return Value
Type: Boolean
isEndElement()
Signature
public Boolean isEndElement()
Return Value
Type: Boolean
isStartElement()
Signature
public Boolean isStartElement()
Return Value
Type: Boolean
isWhiteSpace()
Signature
public Boolean isWhiteSpace()
Return Value
Type: Boolean
next()
Signature
public Integer next()
Return Value
Type: Integer
nextTag()
Signature
public Integer nextTag()
Return Value
Type: Integer
Usage
This method throws an error if elements other than white space, comments, processing instruction, start elements or stop elements are encountered.
setCoalescing(returnAsSingleBlock)
Signature
public Void setCoalescing(Boolean returnAsSingleBlock)
Parameters
-
returnAsSingleBlock:
Type: Boolean
Return Value
Type: Void
setNamespaceAware(isNamespaceAware)
Signature
public Void setNamespaceAware(Boolean isNamespaceAware)
Parameters
-
isNamespaceAware:
Type: Boolean
Return Value
Type: Void
toString()
Signature
public String toString()
Return Value
Type: String