Class Xml
- All Implemented Interfaces:
AutoCloseable
Load, navigate, search, edit, transform, and save in-memory XML trees.
Chilkat.Xml is the primary Chilkat class for in-memory XML tree
manipulation. It supports loading and saving XML, navigating between elements,
reading and writing text content, managing attributes, working with
namespaces, adding and removing subtrees, searching by tag, content, or
attribute, sorting child records, scrubbing XML, handling CDATA and XML
declarations, storing binary data as Base64, and optionally compressing or
encrypting element content.
Load and save XML
Load XML from strings, files, byte data, or other Chilkat objects, then save or emit formatted XML when processing is complete.
Navigate XML trees
Move through parent, child, sibling, and selected elements while working directly with the XML document structure.
Edit elements and attributes
Add, update, remove, or rename elements; set text content; and read, add, modify, or delete attributes.
Search and select
Locate elements by tag name, content, path, attribute value, or custom search patterns.
Namespaces and structure
Work with namespace-aware XML, declarations, CDATA, child ordering, sorting, and subtree insertion or removal.
Binary and protected content
Store binary data as Base64 and optionally compress or encrypt element content when XML carries encoded payloads.
Important usage distinction:
Some methods return a new Xml object reference for the selected
element, while methods ending in 2 update the caller's internal
reference to point to a different element. This distinction is central when
navigating and editing XML trees because it determines whether the current
object stays where it is or moves to another element.
Common pattern:
Load or create the XML document, navigate to the element of interest, read or
modify content and attributes, add or remove child elements as needed, then
save the updated XML. Use Chilkat.Xml for tree-oriented XML
manipulation, and use Chilkat.XmlDSig,
Chilkat.XmlDSigGen, or related classes when the task is XML
digital signing or signature verification.
For an extended overview, see Xml Class Overview.
</section>
Instances hold a native Chilkat object: close them with ChilkatObject.close() (try-with-resources) when
done; an unclosed instance is freed when it becomes unreachable.
- See Also:
- Online reference
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaccumulateTagContent(String tag, String skipTags)Traverses the subtree rooted at the calling element and concatenates the text content of all elements whose tag equalstag.voidaddAttribute(String name, String value)Adds an attribute namednamewith the specified stringvalueto the calling element.voidaddAttributeInt(String name, int value)Adds an attribute namednamewhose value is the decimal representation ofvalue.voidaddChildTree(Xml tree)Adds the entire XML subtree referenced bytreeas a new direct child of the calling element.voidaddOrUpdateAttribute(String name, String value)Sets the string value of an attribute on the calling element.voidaddOrUpdateAttributeI(String name, int value)Sets an integer-valued attribute on the calling element.voidaddStyleSheet(String styleSheet)Adds an XML stylesheet processing instruction to the document.voidaddToAttribute(String name, int amount)Treats the named attribute value as an integer, addsamount, and stores the resulting integer back in the attribute.voidaddToChildContent(String tag, int amount)Finds the child identified bytag, interprets its content as an integer, addsamount, and stores the resulting integer as the child's new content.voidaddToContent(int amount)Interprets this element's content as an integer, addsamount, and stores the resulting integer as the new content.voidappendToContent(String str)Appendsstrto the existing text content of the calling element without replacing its child elements.booleanchildContentMatches(String tagPath, String pattern, boolean caseSensitive)Returnstrueif the child identified bytagPathhas content matchingpattern; otherwise returnsfalse.chilkatPath(String pathCmd)Evaluates a Chilkat-specific path command that can navigate from the current element, return element content or an attribute value, or move the caller's internal element reference.voidclear()Clears the calling element by removing all child elements, attributes, and text content, and resets its tag name tounnamed.booleancontentMatches(String pattern, boolean caseSensitive)Returnstrueif this element's content matchespattern; otherwise returnsfalse.voidCopies theTag,Content, and attributes fromnodeto the calling element.voidChanges thisXmlobject so that it references the same underlying XML element ascopyFromNode.decodeEntities(String str)Decodes HTML character entities found instrand returns the decoded text.voiddecryptContent(String password)Decrypts element content previously produced byEncryptContent, using the same password, and restores the original plaintext content.voidencryptContent(String password)Encrypts the calling element's text content using Chilkat's password-based 128-bit AES-CBC format and replaces the plaintext content with Base64-encoded encrypted data.extractChildByIndex(int index)Removes the direct child at zero-basedindexfrom the calling element and returns anXmlobject for the detached child subtree.extractChildByName(String tagPath, String attrName, String attrValue)Finds, removes, and returns the first child selected bytagPathand the optional attribute criteria.Returns anXmlobject referencing the child selected bytagPath.voidfindChild2(String tagPath)Moves the callingXmlobject's internal reference to the child selected bytagPath.findNextRecord(String tagPath, String contentPattern)Finds the next direct child record for which the descendant identified bytagPathhas content matchingcontentPattern.findOrAddNewChild(String tagPath)Returns the child selected bytagPathif it already exists.Returns anXmlobject referencing the first direct child of the calling element.booleanMoves the callingXmlobject's internal reference to its first direct child.getAttributeName(int index)Returns the name of the attribute at zero-basedindex.getAttributeValue(int index)Returns the value of the attribute at zero-basedindex.intgetAttributeValueInt(int index)Returns the value of the attribute at zero-basedindex, interpreted as a 32-bit integer.getAttrValue(String name)Returns the value of the attribute namednameon the calling element.intgetAttrValueInt(String name)Returns the value of the attribute namednameinterpreted as a 32-bit integer.booleangetCdata()Controls how this element's text content is emitted.getChild(int index)Returns anXmlobject referencing the direct child at zero-basedindex.voidgetChild2(int index)Moves the callingXmlobject's internal reference to the direct child at zero-basedindex.getChildAttrValue(String tagPath, String attrName)Returns the value of attributeattrNameon the descendant element selected bytagPath.booleangetChildBoolValue(String tagPath)Returns the integer content of the child selected bytagPathas a Boolean value: content equal to0yieldsfalse; a non-zero integer yieldstrue.getChildContent(String tagPath)Returns the text content of the child selected bytagPath.getChildContentByIndex(int index)Returns the text content of the direct child at zero-basedindex.voidgetChildContentSb(String tagPath, StringBuilder sb)Finds the element selected bytagPathand appends that element's text content tosb.getChildExact(String tag, String content)Returns the first direct child whose tag equalstagand whose text content exactly equalscontent.intgetChildIntValue(String tagPath)Returns the content of the child selected bytagPath, interpreted as a 32-bit integer.getChildTag(int index)Returns the tag name of the direct child at zero-basedindex.getChildTagByIndex(int index)Returns the tag name of the direct child at zero-basedindex.getChildWithAttr(String tagPath, String attrName, String attrValue)Returns the child selected bytagPaththat also has an attribute namedattrNamewhose value exactly equalsattrValue.getChildWithContent(String content)Returns the first direct child whose text content exactly equalscontent.getChildWithTag(String tagPath)Returns anXmlobject referencing the child selected bytagPath.voidgetChildWithTag2(String tagPath)Moves the callingXmlobject's internal reference to the child selected bytagPath.Gets or sets the text content stored directly on this XML element.intGets or sets this element's content as a 32-bit integer.Gets or sets the document type declaration associated with the XML document.booleanControls whether a byte order mark (BOM, also called a preamble) is written when XML is saved to a file.booleanControls whether XML emitted byGetXmlandGetXmlSbis compact.booleanControls whether the XML declaration is included when XML is emitted.Gets or sets theencodingvalue used in the XML declaration.intgetI()Provides a substitution value for[i]in Chilkat tag paths andChilkatPathexpressions.booleanReturnstrueif this element's content consists only of characters allowed in standard Base64 text, with whitespace ignored.intgetJ()Provides a substitution value for[j]in Chilkat tag paths andChilkatPathexpressions.intgetK()Provides a substitution value for[k]in Chilkat tag paths andChilkatPathexpressions.getNthChildWithTag(String tag, int n)Returns the zero-basednth direct child whose tag exactly equalstag.voidgetNthChildWithTag2(String tag, int n)Moves the callingXmlobject's internal reference to the zero-basednth direct child whose tag equalstag.intReturns the number of attributes on this element.intReturns the number of direct child elements of this element.Returns anXmlobject referencing this element's parent.voidMoves the callingXmlobject's internal reference to its parent.getRoot()Returns anXmlobject referencing the root element of the XML tree that contains the current element.voidgetRoot2()Moves the callingXmlobject's internal reference to the root element of its XML tree.getSelf()Returns a newXmlobject that references the same underlying XML element as the calling object.booleanControls case sensitivity for the XML sorting methods.booleanControls thestandalonepseudo-attribute in the XML declaration.booleanWhenStrictis true, the XML loading methods first check that the input is well-formed XML.getTag()Gets or sets the element name for this element, including any namespace prefix.Gets or sets the namespace prefix portion of this element's tag.Returns the Chilkat tag path needed to reach this element from the document root.Gets or sets the unprefixed portion of this element's tag.intReturns the identifier of the XML tree to which this element belongs.Provides a catch-all string for uncommon XML behaviors.getXml()Serializes the XML tree or subtree rooted at the current element and returns the XML text.voidSerializes the XML tree or subtree rooted at the current element and appends the encoded XML bytes tobd.voidgetXmlSb(StringBuilder sb)Serializes the XML tree or subtree rooted at the current element and appends the resulting XML text tosb.booleanhasAttribute(String name)Returnstrueif the calling element has an attribute namedname; otherwise returnsfalse.booleanhasAttrWithValue(String name, String value)Returnstrueif the calling element has an attribute namednamewhose value exactly equalsvalue; otherwise returnsfalse.booleanhasChildWithContent(String content)Returnstrueif any direct child has text content exactly equal tocontent; otherwise returnsfalse.booleanhasChildWithTag(String tagPath)Returnstrueif the child selected bytagPathexists; otherwise returnsfalse.booleanhasChildWithTagAndContent(String tagPath, String content)Returnstrueif the child selected bytagPathexists and its text content exactly equalscontent; otherwise returnsfalse.voidinsertChildTreeAfter(int index, Xml tree)Inserts the entire subtree referenced bytreeas a direct child immediately after the existing child at zero-basedindex.voidinsertChildTreeBefore(int index, Xml tree)Inserts the entire subtree referenced bytreeas a direct child immediately before the existing child at zero-basedindex.Returns anXmlobject referencing the last direct child of the calling element.voidMoves the callingXmlobject's internal reference to its last direct child.voidParses XML from the bytes contained inbdand replaces the calling object's current XML tree with the loaded document.voidloadSb(StringBuilder sb, boolean autoTrim)Parses XML from the current contents ofsband replaces the calling object's current XML tree with the loaded document.voidParses the XML text inxmlDataand replaces the calling object's current XML tree content with the loaded document root.voidParses the XML text inxmlDataand replaces the current XML tree, likeLoadXml.voidloadXmlFile(String fileName)Reads and parses an XML document fromfileName, replacing the calling object's current XML tree with the loaded document root.voidloadXmlFile2(String fileName, boolean autoTrim)Reads and parses an XML document fromfileName, replacing the current XML tree.Creates and returns a new child attagPathwith the specified textcontent.voidCreates a new child attagPathwith the specified textcontent, but does not return a separateXmlobject for the new element.newChildAfter(int index, String tag, String content)Creates a new direct child with the specifiedtagandcontent, inserts it immediately after the child at zero-basedindex, and returns the new child element.newChildBefore(int index, String tag, String content)Creates a new direct child with the specifiedtagandcontent, inserts it immediately before the child at zero-basedindex, and returns the new child element.voidnewChildInt2(String tagPath, int value)Creates a new child attagPathwhose content is the decimal representation ofvalue.booleannextInTraversal2(StringBuilder sbState)Moves the callingXmlobject to the next element in a depth-first traversal of the tree and updatessbStatewith the traversal state.Returns anXmlobject referencing the current element's next sibling, or no object when there is no next sibling.booleanMoves the callingXmlobject's internal reference to its next sibling.intnumChildrenAt(String tagPath)Returns the number of direct children of the element selected bytagPath.intnumChildrenHavingTag(String tag)Returns the number of direct children whose tag exactly equalstag.Returns anXmlobject referencing the current element's previous sibling, or no object when there is no previous sibling.voidMoves the callingXmlobject's internal reference to its previous sibling.intpruneAttribute(String attrName)Recursively traverses the subtree rooted at the calling element and removes every occurrence of the attribute namedattrName.intRecursively traverses the subtree rooted at the calling element and removes every element whose tag equalstag.voidRemoves every attribute from the calling element.voidRemoves all direct child elements and their subtrees from the calling element.voidremoveAttribute(String name)Removes the attribute namednamefrom the calling element.voidremoveChild(String tagPath)Removes all child elements selected bytagPathbeneath the calling element.voidremoveChildByIndex(int index)Removes the direct child at zero-basedindex, including that child's entire subtree.voidremoveChildWithContent(String content)Removes all direct children whose text content exactly equalscontent, including each removed child's subtree.voidDetaches the calling element and its entire subtree from its parent.intremoveStyleSheet(String attrName, String attrValue)Removes XML stylesheet processing instructions whose attribute namedattrNamehas the valueattrValue.voidsaveBinaryContent(String filename, boolean unzipFlag, boolean decryptFlag, String password)Decodes the binary content stored in this element and writes the resulting bytes tofilename.voidSerializes the XML tree or subtree rooted at the current element and writes it tofileName.voidRecursively normalizes the XML subtree rooted at the calling element according to the comma-separated keywords indirectives.searchAllForContent(Xml after, String contentPattern)Returns the first element whose text content matchescontentPattern, regardless of tag name.voidsearchAllForContent2(Xml after, String contentPattern)Performs the same breadth-first content search asSearchAllForContent, but moves the callingXmlobject's internal reference to the matching element instead of returning a separate element object.searchForAttribute(Xml after, String tag, String attr, String valuePattern)Returns the first element whose tag equalstag, that has an attribute namedattr, and whose attribute value matchesvaluePattern.voidsearchForAttribute2(Xml after, String tag, String attr, String valuePattern)Performs the same breadth-first tag/attribute search asSearchForAttribute, but moves the callingXmlobject's internal reference to the matching element instead of returning a separate object.searchForContent(Xml after, String tag, String contentPattern)Returns the first element whose tag equalstagand whose text content matchescontentPattern.voidsearchForContent2(Xml after, String tag, String contentPattern)Performs the same breadth-first tag/content search asSearchForContent, but moves the callingXmlobject's internal reference to the matching element.searchForTag(Xml after, String tag)Returns the first element whose tag exactly equalstag.voidsearchForTag2(Xml after, String tag)Performs the same breadth-first tag search asSearchForTag, but moves the callingXmlobject's internal reference to the matching element instead of returning a separate object.voidsetBinaryContentBd(BinData data, boolean zipFlag, boolean encryptFlag, String password)Stores the bytes indataas binary content on this element, with optional ZIP compression and optional password-based AES encryption.voidsetBinaryContentFromFile(String filename, boolean zipFlag, boolean encryptFlag, String password)Reads the bytes fromfilenameand stores them as this element's binary content, with optional ZIP compression and optional password-based encryption.voidsetCdata(boolean value)Sets theCdataproperty; seegetCdata().voidsetContent(String value)Sets theContentproperty; seegetContent().voidsetContentInt(int value)Sets theContentIntproperty; seegetContentInt().voidsetDocType(String value)Sets theDocTypeproperty; seegetDocType().voidsetEmitBom(boolean value)Sets theEmitBomproperty; seegetEmitBom().voidsetEmitCompact(boolean value)Sets theEmitCompactproperty; seegetEmitCompact().voidsetEmitXmlDecl(boolean value)Sets theEmitXmlDeclproperty; seegetEmitXmlDecl().voidsetEncoding(String value)Sets theEncodingproperty; seegetEncoding().voidsetI(int value)Sets theIproperty; seegetI().voidsetJ(int value)Sets theJproperty; seegetJ().voidsetK(int value)Sets theKproperty; seegetK().voidsetSortCaseInsensitive(boolean value)Sets theSortCaseInsensitiveproperty; seegetSortCaseInsensitive().voidsetStandalone(boolean value)Sets theStandaloneproperty; seegetStandalone().voidsetStrict(boolean value)Sets theStrictproperty; seegetStrict().voidSets theTagproperty; seegetTag().voidsetTagNsPrefix(String value)Sets theTagNsPrefixproperty; seegetTagNsPrefix().voidsetTagUnprefixed(String value)Sets theTagUnprefixedproperty; seegetTagUnprefixed().voidsetUncommonOptions(String value)Sets theUncommonOptionsproperty; seegetUncommonOptions().voidsortByAttribute(String attrName, boolean ascending)Sorts the calling element's direct children by the string value of attributeattrName.voidsortByAttributeInt(String attrName, boolean ascending)Sorts the calling element's direct children numerically by the value of attributeattrName, interpreting each sort value as an integer rather than comparing the text lexicographically.voidsortByContent(boolean ascending)Sorts the calling element's direct children by their text content.voidsortByTag(boolean ascending)Sorts the calling element's direct children by tag name.voidsortRecordsByAttribute(String sortTag, String attrName, boolean ascending)Treats each direct child as a record and sorts those records by the value of attributeattrNameon the record's child identified bysortTag.voidsortRecordsByContent(String sortTag, boolean ascending)Treats each direct child as a record and sorts those records by the text content of the record's child namedsortTag.voidsortRecordsByContentInt(String sortTag, boolean ascending)Treats each direct child as a record and sorts those records numerically by the integer content of the record's child namedsortTag.voidSwaps the calling element's tag, text content, and attributes with those ofnode.voidSwaps the calling element's complete tree state withtree, including tag, text content, attributes, and children.tagContent(String tagName)Searches the subtree rooted at the calling element for the first element whose tag equalstagNameand returns that element's text content.booleanReturnstrueif the calling element's complete tag name, including any namespace prefix, exactly equalstag; otherwise returnsfalse.intReturns the zero-based child index of the element selected bytagPath.booleantagNsEquals(String ns)Returnstrueif this element's namespace-prefix portion exactly equalsns; otherwise returnsfalse.booleantagUnpEquals(String unprefixedTag)Returnstrueif this element's unprefixed tag exactly equalsunprefixedTag; otherwise returnsfalse.voidReversesZipContent: decodes and decompresses the calling element's compressed content and replaces the stored Base64-compressed representation with the original content.voidReversesZipTree: decompresses the stored representation and reconstructs the calling element's previously compressed subtree.voidSets the text content of the element selected bytagPathtovalue.voidupdateAttrAt(String tagPath, boolean autoCreate, String attrName, String attrValue)Sets attributeattrNametoattrValueon the element selected bytagPath.voidupdateAttribute(String attrName, String attrValue)Sets attributeattrNametoattrValue.voidupdateAttributeInt(String attrName, int value)Sets attributeattrNameto the decimal representation of integervalue.voidupdateChildContent(String tagPath, String value)Sets the text content of the child selected bytagPathtovalue.voidupdateChildContentInt(String tagPath, int value)Sets the content of the child selected bytagPathto the decimal representation of integervalue.voidZIP-compresses this element's text content and replaces the original content with Base64-encoded compressed data.voidzipTree()ZIP-compresses the calling element's content together with its entire child subtree and replaces that structure with Base64-encoded compressed data.Methods inherited from class com.chilkatsoft.chilkat2.ChilkatObject
close, getDebugLogFilePath, getLastErrorHtml, getLastErrorText, getLastErrorXml, getLastMethodSuccess, getVerboseLogging, getVersion, isClosed, setDebugLogFilePath, setLastMethodSuccess, setVerboseLogging, toString
-
Constructor Details
-
Xml
public Xml()Creates a newXmlobject.
-
-
Method Details
-
getCdata
public boolean getCdata()Controls how this element's text content is emitted. When set totrue, the element content is written inside a CDATA section instead of being emitted as ordinary character data with XML escaping. CDATA and escaping: CDATA is useful when text contains many characters such as<or&. It does not change the logical text value of the element; it only changes how that text is represented in the serialized XML.- Returns:
- the value of the
Cdataproperty
-
setCdata
public void setCdata(boolean value)Sets theCdataproperty; seegetCdata().- Parameters:
value- the new value
-
getContent
Gets or sets the text content stored directly on this XML element. Child elements are not included in this value.For example, both of the following elements have
This is the contentas theirContent:_LT_tag1_GT_This is the content_LT_/tag1_GT_ _LT_tag2_GT__LT_child1_GT_abc_LT_/child1_GT__LT_child2_GT_abc_LT_/child2_GT_This is the content_LT_/tag2_GT_
Content vs. children: Chilkat stores an element's direct text content separately from its child elements. Use the child-navigation methods when you need the nested elements themselves.
- Returns:
- the value of the
Contentproperty
-
setContent
Sets theContentproperty; seegetContent().- Parameters:
value- the new value (notnull)
-
getContentInt
public int getContentInt()Gets or sets this element's content as a 32-bit integer. Setting the property converts the integer to its decimal text representation; getting the property interprets the element's text content as an integer. Numeric content: UseContentwhen the value may exceed the range of a 32-bit integer or when the exact lexical representation must be preserved.- Returns:
- the value of the
ContentIntproperty
-
setContentInt
public void setContentInt(int value)Sets theContentIntproperty; seegetContentInt().- Parameters:
value- the new value
-
getDocType
Gets or sets the document type declaration associated with the XML document.The value represents the document-level
DOCTYPEdeclaration, for example_LT_!DOCTYPE note SYSTEM "note.dtd"_GT_.Document-level setting: Although this property may be accessed from any element reference in the tree, the DOCTYPE belongs to the XML document as a whole rather than to an individual element.
- Returns:
- the value of the
DocTypeproperty
-
setDocType
Sets theDocTypeproperty; seegetDocType().- Parameters:
value- the new value (notnull)
-
getEmitBom
public boolean getEmitBom()Controls whether a byte order mark (BOM, also called a preamble) is written when XML is saved to a file. The default isfalse.This setting is relevant to encodings for which a BOM can be emitted, such as UTF-8 and UTF-16. It does not affect XML returned as a language string by methods such as
GetXml.- Returns:
- the value of the
EmitBomproperty
-
setEmitBom
public void setEmitBom(boolean value)Sets theEmitBomproperty; seegetEmitBom().- Parameters:
value- the new value
-
getEmitCompact
public boolean getEmitCompact()Controls whether XML emitted byGetXmlandGetXmlSbis compact. Whentrue, unnecessary formatting whitespace and line breaks are omitted. The default isfalsefor backward compatibility. Formatting only: Compact output changes presentation, not the XML tree or its element content.- Returns:
- the value of the
EmitCompactproperty
-
setEmitCompact
public void setEmitCompact(boolean value)Sets theEmitCompactproperty; seegetEmitCompact().- Parameters:
value- the new value
-
getEmitXmlDecl
public boolean getEmitXmlDecl()Controls whether the XML declaration is included when XML is emitted. The default istrue. When set tofalse, output methods such asGetXmlandSaveXmlomit the declaration.An XML declaration is the leading construct such as
_LT_?xml version="1.0" encoding="utf-8"?_GT_.- Returns:
- the value of the
EmitXmlDeclproperty
-
setEmitXmlDecl
public void setEmitXmlDecl(boolean value)Sets theEmitXmlDeclproperty; seegetEmitXmlDecl().- Parameters:
value- the new value
-
getEncoding
Gets or sets theencodingvalue used in the XML declaration. The default isutf-8. This is a document-level setting and may be accessed from any element in the tree.When XML is loaded, Chilkat sets this property from the encoding declared by the input XML when one is present. If no encoding is declared, the property is reset to
utf-8.Important: Changing
Encodingchanges the declared/output encoding used when XML is serialized; it does not reinterpret or transcode the already-stored Unicode text inside the in-memory tree.- Returns:
- the value of the
Encodingproperty
-
setEncoding
Sets theEncodingproperty; seegetEncoding().- Parameters:
value- the new value (notnull)
-
getI
public int getI()Provides a substitution value for[i]in Chilkat tag paths andChilkatPathexpressions. When a path contains[i], the current value of this property is substituted for I. Loop-friendly paths: TheI,J, andKproperties make it convenient to reuse a path expression inside nested loops without constructing a new path string for every index.- Returns:
- the value of the
Iproperty
-
setI
public void setI(int value)Sets theIproperty; seegetI().- Parameters:
value- the new value
-
getIsBase64
public boolean getIsBase64()Returnstrueif this element's content consists only of characters allowed in standard Base64 text, with whitespace ignored. Standard Base64 usesA-Z,a-z,0-9,+,/, and optional trailing=padding. Syntax check, not semantic validation: A value can contain only Base64 characters and still not represent the data your application expects. This property is useful as a quick content-format test.- Returns:
- the value of the
IsBase64property (read-only)
-
getJ
public int getJ()Provides a substitution value for[j]in Chilkat tag paths andChilkatPathexpressions. When a path contains[j], the current value of this property is substituted for J. Loop-friendly paths: TheI,J, andKproperties make it convenient to reuse a path expression inside nested loops without constructing a new path string for every index.- Returns:
- the value of the
Jproperty
-
setJ
public void setJ(int value)Sets theJproperty; seegetJ().- Parameters:
value- the new value
-
getK
public int getK()Provides a substitution value for[k]in Chilkat tag paths andChilkatPathexpressions. When a path contains[k], the current value of this property is substituted for K. Loop-friendly paths: TheI,J, andKproperties make it convenient to reuse a path expression inside nested loops without constructing a new path string for every index.- Returns:
- the value of the
Kproperty
-
setK
public void setK(int value)Sets theKproperty; seegetK().- Parameters:
value- the new value
-
getNumAttributes
public int getNumAttributes()Returns the number of attributes on this element.For example,
_LT_tag attr1="value1" attr2="value2"_GT_..._LT_/tag_GT_has two attributes. Attribute indexes used by methods such asGetAttributeNameandGetAttributeValueare zero-based.- Returns:
- the value of the
NumAttributesproperty (read-only)
-
getNumChildren
public int getNumChildren()Returns the number of direct child elements of this element. Descendants below those children are not included in the count. Direct children only: Use traversal or search methods when you need to inspect the entire subtree rather than only the immediate children.- Returns:
- the value of the
NumChildrenproperty (read-only)
-
getSortCaseInsensitive
public boolean getSortCaseInsensitive()Controls case sensitivity for the XML sorting methods. Set totruefor case-insensitive string comparisons orfalsefor case-sensitive comparisons.- Returns:
- the value of the
SortCaseInsensitiveproperty
-
setSortCaseInsensitive
public void setSortCaseInsensitive(boolean value)Sets theSortCaseInsensitiveproperty; seegetSortCaseInsensitive().- Parameters:
value- the new value
-
getStandalone
public boolean getStandalone()Controls thestandalonepseudo-attribute in the XML declaration. This is a document-level setting and may be accessed from any element in the tree.Setting this property to
truecauses the declaration to includestandalone="yes".XML declaration: The standalone declaration concerns whether the document relies on external markup declarations. It is metadata in the XML declaration; it does not by itself validate or alter the document.
- Returns:
- the value of the
Standaloneproperty
-
setStandalone
public void setStandalone(boolean value)Sets theStandaloneproperty; seegetStandalone().- Parameters:
value- the new value
-
getStrict
public boolean getStrict()WhenStrictis true, the XML loading methods first check that the input is well-formed XML. If it is not, the load fails and the contents of this Xml object are left unchanged. The default isfalse.This applies to
,loadXml(String),loadXml2(String, boolean),loadSb(StringBuilder, boolean),loadBd(BinData, boolean)andloadXmlFile(String).loadXmlFile2(String, boolean)Chilkat's XML parser is deliberately tolerant. By default it can accept input that is not well-formed, succeed, and leave a partially populated tree. That is convenient when the goal is a best-effort parse of imperfect input, but it is the wrong behavior when a silently dropped element or attribute changes what the application does.
Set
Stricttotruefor XML carrying configuration, credentials, signed content, or security parameters, where an element that quietly failed to load would be acted on as though it had never been present.The check is for XML 1.0 well-formedness only. It is not a validating parse: no DTD or schema is read, and the document is not checked against one. Markup declarations inside an internal DTD subset are skipped rather than parsed.
Note: The default is
falseso that existing applications are unaffected. When a strict load is rejected, this Xml object keeps whatever it held before the call, so a failed reload never leaves the object empty.- Returns:
- the value of the
Strictproperty
-
setStrict
public void setStrict(boolean value)Sets theStrictproperty; seegetStrict().- Parameters:
value- the new value
-
getTag
Gets or sets the element name for this element, including any namespace prefix. For example, the tag for_LT_soapenv:Body_GT_issoapenv:Body.Use
TagNsPrefixandTagUnprefixedwhen the prefix and local portion are needed separately.- Returns:
- the value of the
Tagproperty
-
setTag
Sets theTagproperty; seegetTag().- Parameters:
value- the new value (notnull)
-
getTagNsPrefix
Gets or sets the namespace prefix portion of this element's tag. Forsoapenv:Envelope, the namespace prefix issoapenv. Prefix vs. namespace URI: This property deals with the lexical prefix in the tag name. A prefix is not itself the namespace URI; namespace bindings are expressed throughxmlnsattributes in the XML.- Returns:
- the value of the
TagNsPrefixproperty
-
setTagNsPrefix
Sets theTagNsPrefixproperty; seegetTagNsPrefix().- Parameters:
value- the new value (notnull)
-
getTagPath
Returns the Chilkat tag path needed to reach this element from the document root. If this object currently references the root element, the returned path is the empty string. Not XPath: A Chilkat tag path is Chilkat's own navigation syntax, typically using|between element names. It is not an XPath expression.- Returns:
- the value of the
TagPathproperty (read-only)
-
getTagUnprefixed
Gets or sets the unprefixed portion of this element's tag. Forsoapenv:Envelope, the unprefixed tag isEnvelope.Use
TagNsPrefixto access the prefix separately.- Returns:
- the value of the
TagUnprefixedproperty
-
setTagUnprefixed
Sets theTagUnprefixedproperty; seegetTagUnprefixed().- Parameters:
value- the new value (notnull)
-
getTreeId
public int getTreeId()Returns the identifier of the XML tree to which this element belongs. Elements in the same XML document have the sameTreeId. Useful for element references: MultipleXmlobjects can reference different elements in the same underlying tree. ComparingTreeIdvalues is a convenient way to determine whether two element references belong to that same tree.- Returns:
- the value of the
TreeIdproperty (read-only)
-
getUncommonOptions
Provides a catch-all string for uncommon XML behaviors. The default is the empty string, which is appropriate for normal use.Leave this property empty unless Chilkat documentation or support identifies a specific option needed for a specialized interoperability case.
- Returns:
- the value of the
UncommonOptionsproperty
-
setUncommonOptions
Sets theUncommonOptionsproperty; seegetUncommonOptions().- Parameters:
value- the new value (notnull)
-
accumulateTagContent
Traverses the subtree rooted at the calling element and concatenates the text content of all elements whose tag equalstag.skipTagsis a vertical-bar-delimited list of tag names whose entire subtrees are excluded from the accumulation. For example,script|styleskips elements rooted at either of those tags.- Parameters:
tag- thetagargument (notnull)skipTags- theskipTagsargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
addAttribute
Adds an attribute namednamewith the specified stringvalueto the calling element.Returns
trueon success andfalseon failure.When an attribute may already exist: Use
AddOrUpdateAttributeorUpdateAttributewhen the desired behavior is to update an existing attribute value instead of requiring a new attribute.- Parameters:
name- thenameargument (notnull)value- thevalueargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
addAttributeInt
Adds an attribute namednamewhose value is the decimal representation ofvalue.Returns
trueon success andfalseon failure.- Parameters:
name- thenameargument (notnull)value- thevalueargument- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
addChildTree
Adds the entire XML subtree referenced bytreeas a new direct child of the calling element.If
treealready belongs to another XML document, the subtree is transferred to the destination tree rather than copied as an unrelated duplicate.Tree ownership: After moving a subtree between documents, its elements belong to the destination tree.
TreeIdcan be used to determine which tree an element reference belongs to.- Parameters:
tree- thetreeargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
addOrUpdateAttribute
Sets the string value of an attribute on the calling element. If an attribute namednamealready exists, its value is replaced; otherwise the attribute is added.- Parameters:
name- thenameargument (notnull)value- thevalueargument (notnull)
-
addOrUpdateAttributeI
Sets an integer-valued attribute on the calling element. If an attribute namednamealready exists, its value is replaced with the decimal representation ofvalue; otherwise the attribute is added.- Parameters:
name- thenameargument (notnull)value- thevalueargument
-
addStyleSheet
Adds an XML stylesheet processing instruction to the document. Pass the complete processing-instruction text, for example:_LT_?xml-stylesheet href="mystyle.css" title="Compact" type="text/css"?_GT_
Processing instruction: An XML stylesheet declaration associates stylesheet metadata with the XML document; it does not apply or execute the stylesheet.
- Parameters:
styleSheet- thestyleSheetargument (notnull)
-
addToAttribute
Treats the named attribute value as an integer, addsamount, and stores the resulting integer back in the attribute.If the attribute does not yet exist, this method behaves like
AddOrUpdateAttributeIand creates it withamountas the value.- Parameters:
name- thenameargument (notnull)amount- theamountargument
-
addToChildContent
Finds the child identified bytag, interprets its content as an integer, addsamount, and stores the resulting integer as the child's new content.- Parameters:
tag- thetagargument (notnull)amount- theamountargument
-
addToContent
public void addToContent(int amount)Interprets this element's content as an integer, addsamount, and stores the resulting integer as the new content.- Parameters:
amount- theamountargument
-
appendToContent
Appendsstrto the existing text content of the calling element without replacing its child elements.Returns
trueon success andfalseon failure.- Parameters:
str- thestrargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
childContentMatches
Returnstrueif the child identified bytagPathhas content matchingpattern; otherwise returnsfalse.caseSensitivecontrols whether letter case is significant.The pattern may contain
*wildcards, where each asterisk matches zero or more characters.Tag paths: A tag path is Chilkat's
|-separated child-navigation syntax, for exampletagA|tagB|tagC. It is not XPath.- Parameters:
tagPath- thetagPathargument (notnull)pattern- thepatternargument (notnull)caseSensitive- thecaseSensitiveargument- Returns:
- the result; this method never throws
ChilkatException
-
chilkatPath
Evaluates a Chilkat-specific path command that can navigate from the current element, return element content or an attribute value, or move the caller's internal element reference.This syntax is not XPath. Commands are separated by vertical bars and the expression ends with a return command:
command|command|command|...|returnCommand
Navigation commands include:
TagName- first direct child having that tag.TagName[n]- the indexed direct child having that tag...- parent.++/--- next / previous sibling.TagName{Content}- first direct child with that tag and exact content./T/TagName- traverse the subtree and find the first element with that tag./C/TagName,ContentPattern- traverse for a tag whose content matches a wildcard pattern./C/ContentPattern- traverse for any tag whose content matches a wildcard pattern./A/TagName,AttrName,AttrValuePattern- traverse for a tag having a matching attribute value.
The final return command is:
*- return the current element's content.(AttrName)- return an attribute value.$- move thisXmlobject to the selected element and return an empty string.
Index substitution: The
I,J, andKproperties can be used with[i],[j], and[k]in path expressions.- Parameters:
pathCmd- thepathCmdargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
clear
public void clear()Clears the calling element by removing all child elements, attributes, and text content, and resets its tag name tounnamed.The element itself remains in the tree; this method clears its contents rather than removing the element from its parent.
-
contentMatches
Returnstrueif this element's content matchespattern; otherwise returnsfalse.caseSensitivecontrols whether letter case is significant.The pattern may contain
*wildcards, where each asterisk matches zero or more characters.- Parameters:
pattern- thepatternargument (notnull)caseSensitive- thecaseSensitiveargument- Returns:
- the result; this method never throws
ChilkatException
-
copy
Copies theTag,Content, and attributes fromnodeto the calling element. Not a subtree copy: This method does not copy the source element's children. Use a tree-oriented method such asAddChildTreeorSwapTreewhen child structure is part of the operation.- Parameters:
node- thenodeargument (notnull)
-
copyRef
Changes thisXmlobject so that it references the same underlying XML element ascopyFromNode. The caller's previous element reference is discarded. Reference operation:CopyRefdoes not copy XML data. After the call, bothXmlobjects refer to the same element, so edits through either reference affect the same tree element.- Parameters:
copyFromNode- thecopyFromNodeargument (notnull)
-
decodeEntities
Decodes HTML character entities found instrand returns the decoded text. This is a utility operation; it does not modify the XML tree unless the returned string is assigned to an element.For example, an HTML entity such as
&is decoded to&.- Parameters:
str- thestrargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
decryptContent
Decrypts element content previously produced byEncryptContent, using the same password, and restores the original plaintext content.Returns
trueon success andfalseon failure.Compatibility-oriented encryption: This method is paired specifically with
EncryptContent. It is not a general XML Encryption (XML-Enc) implementation.- Parameters:
password- thepasswordargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
encryptContent
Encrypts the calling element's text content using Chilkat's password-based 128-bit AES-CBC format and replaces the plaintext content with Base64-encoded encrypted data.Returns
trueon success andfalseon failure.Scope: Only this element's content is encrypted. The tag, attributes, and child elements are not encrypted by this method. Use
DecryptContentwith the same password to restore the content.- Parameters:
password- thepasswordargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
extractChildByIndex
Removes the direct child at zero-basedindexfrom the calling element and returns anXmlobject for the detached child subtree. Extract vs. remove: UnlikeRemoveChildByIndex, extraction gives the caller a reference to the removed subtree so it can be retained, inspected, or attached elsewhere.- Parameters:
index- theindexargument- Returns:
- a new
Xmlowned by the caller (nevernull); close it when done - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
extractChildByName
Finds, removes, and returns the first child selected bytagPathand the optional attribute criteria.If
attrNameandattrValueare empty, the first child matching the tag/path is extracted. IfattrNameis provided, the child must have that attribute. IfattrValueis also provided, the attribute value must match exactly.Tag paths: A tag path is Chilkat's
|-separated child-navigation syntax, for exampletagA|tagB|tagC. It is not XPath.- Parameters:
tagPath- thetagPathargument (notnull)attrName- theattrNameargument (notnull)attrValue- theattrValueargument (notnull)- Returns:
- a new
Xmlowned by the caller, ornullif not found (no exception is thrown in that case); close it when done
-
findChild
Returns anXmlobject referencing the child selected bytagPath. The calling object remains positioned on its current element. Tag paths: A tag path is Chilkat's|-separated child-navigation syntax, for exampletagA|tagB|tagC. It is not XPath. Element-reference behavior: Methods that return anXmlobject return another object referencing an element in the same underlying tree. Methods whose names end in2instead move the caller's internal reference.- Parameters:
tagPath- thetagPathargument (notnull)- Returns:
- a new
Xmlowned by the caller, ornullif not found (no exception is thrown in that case); close it when done
-
findChild2
Moves the callingXmlobject's internal reference to the child selected bytagPath. Returnstruewhen the child is found and the move succeeds; otherwise returnsfalse. Tag paths: A tag path is Chilkat's|-separated child-navigation syntax, for exampletagA|tagB|tagC. It is not XPath. Element-reference behavior: Methods that return anXmlobject return another object referencing an element in the same underlying tree. Methods whose names end in2instead move the caller's internal reference.- Parameters:
tagPath- thetagPathargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
findNextRecord
Finds the next direct child record for which the descendant identified bytagPathhas content matchingcontentPattern. This is intended for iterating record-like child elements.The content pattern may contain
*wildcards.Tag paths: A tag path is Chilkat's
|-separated child-navigation syntax, for exampletagA|tagB|tagC. It is not XPath.- Parameters:
tagPath- thetagPathargument (notnull)contentPattern- thecontentPatternargument (notnull)- Returns:
- a new
Xmlowned by the caller, ornullif not found (no exception is thrown in that case); close it when done
-
findOrAddNewChild
Returns the child selected bytagPathif it already exists. If it does not exist, creates the required child path with empty content and returns the resulting child element. Tag paths: A tag path is Chilkat's|-separated child-navigation syntax, for exampletagA|tagB|tagC. It is not XPath. UseNewChildinstead when duplicate children with the same tag are intentional.- Parameters:
tagPath- thetagPathargument (notnull)- Returns:
- a new
Xmlowned by the caller (nevernull); close it when done - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
firstChild
Returns anXmlobject referencing the first direct child of the calling element.A common forward-iteration pattern is
FirstChildfollowed by repeated calls toNextSibling.Element-reference behavior: Methods that return an
Xmlobject return another object referencing an element in the same underlying tree. Methods whose names end in2instead move the caller's internal reference.- Returns:
- a new
Xmlowned by the caller, ornullif not found (no exception is thrown in that case); close it when done
-
firstChild2
public boolean firstChild2()Moves the callingXmlobject's internal reference to its first direct child. Returnstrueif a first child exists; otherwise returnsfalse. Element-reference behavior: Methods that return anXmlobject return another object referencing an element in the same underlying tree. Methods whose names end in2instead move the caller's internal reference.- Returns:
- the result; this method never throws
ChilkatException
-
getAttrValue
Returns the value of the attribute namednameon the calling element.Use
HasAttributewhen the application must distinguish a missing attribute from an attribute whose value is empty.- Parameters:
name- thenameargument (notnull)- Returns:
- the result, or
nullif not found (no exception is thrown in that case)
-
getAttrValueInt
Returns the value of the attribute namednameinterpreted as a 32-bit integer. Returns0if the attribute does not exist. Ambiguous zero: Because a missing attribute and an attribute containing zero can both yield0, callHasAttributefirst when that distinction matters.- Parameters:
name- thenameargument (notnull)- Returns:
- the result (see
ChilkatObject.getLastMethodSuccess()where the description mentions failure)
-
getAttributeName
Returns the name of the attribute at zero-basedindex. UseNumAttributesto determine the valid index range.- Parameters:
index- theindexargument- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getAttributeValue
Returns the value of the attribute at zero-basedindex. UseNumAttributesto determine the valid index range.- Parameters:
index- theindexargument- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getAttributeValueInt
public int getAttributeValueInt(int index)Returns the value of the attribute at zero-basedindex, interpreted as a 32-bit integer.- Parameters:
index- theindexargument- Returns:
- the result (see
ChilkatObject.getLastMethodSuccess()where the description mentions failure)
-
getChild
Returns anXmlobject referencing the direct child at zero-basedindex. The calling object remains positioned on its current element.Use
NumChildrento determine the valid child range.Element-reference behavior: Methods that return an
Xmlobject return another object referencing an element in the same underlying tree. Methods whose names end in2instead move the caller's internal reference.- Parameters:
index- theindexargument- Returns:
- a new
Xmlowned by the caller (nevernull); close it when done - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getChild2
public void getChild2(int index)Moves the callingXmlobject's internal reference to the direct child at zero-basedindex. Returnstrueon success andfalseif the child cannot be selected. Element-reference behavior: Methods that return anXmlobject return another object referencing an element in the same underlying tree. Methods whose names end in2instead move the caller's internal reference.- Parameters:
index- theindexargument- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getChildAttrValue
Returns the value of attributeattrNameon the descendant element selected bytagPath. Tag paths: A tag path is Chilkat's|-separated child-navigation syntax, for exampletagA|tagB|tagC. It is not XPath.- Parameters:
tagPath- thetagPathargument (notnull)attrName- theattrNameargument (notnull)- Returns:
- the result, or
nullif not found (no exception is thrown in that case)
-
getChildBoolValue
Returns the integer content of the child selected bytagPathas a Boolean value: content equal to0yieldsfalse; a non-zero integer yieldstrue. Tag paths: A tag path is Chilkat's|-separated child-navigation syntax, for exampletagA|tagB|tagC. It is not XPath.- Parameters:
tagPath- thetagPathargument (notnull)- Returns:
- the result; this method never throws
ChilkatException
-
getChildContent
Returns the text content of the child selected bytagPath. Tag paths: A tag path is Chilkat's|-separated child-navigation syntax, for exampletagA|tagB|tagC. It is not XPath. Content only: The returned value is the child element's directContent; nested child elements are not serialized into this string.- Parameters:
tagPath- thetagPathargument (notnull)- Returns:
- the result, or
nullif not found (no exception is thrown in that case)
-
getChildContentByIndex
Returns the text content of the direct child at zero-basedindex. UseNumChildrento determine the valid range.- Parameters:
index- theindexargument- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getChildContentSb
Finds the element selected bytagPathand appends that element's text content tosb.The existing contents of the
StringBuilderare preserved.Tag paths: A tag path is Chilkat's
|-separated child-navigation syntax, for exampletagA|tagB|tagC. It is not XPath.Returns
trueon success andfalseon failure.- Parameters:
tagPath- thetagPathargument (notnull)sb- thesbargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getChildExact
Returns the first direct child whose tag equalstagand whose text content exactly equalscontent.The calling object remains positioned on its current element.
- Parameters:
tag- thetagargument (notnull)content- thecontentargument (notnull)- Returns:
- a new
Xmlowned by the caller, ornullif not found (no exception is thrown in that case); close it when done
-
getChildIntValue
Returns the content of the child selected bytagPath, interpreted as a 32-bit integer. Tag paths: A tag path is Chilkat's|-separated child-navigation syntax, for exampletagA|tagB|tagC. It is not XPath. Integer range: UseGetChildContentand parse the returned text separately when values may exceed the range of a 32-bit integer.- Parameters:
tagPath- thetagPathargument (notnull)- Returns:
- the result (see
ChilkatObject.getLastMethodSuccess()where the description mentions failure)
-
getChildTag
Returns the tag name of the direct child at zero-basedindex. UseNumChildrento determine the valid index range.- Parameters:
index- theindexargument- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getChildTagByIndex
Returns the tag name of the direct child at zero-basedindex. UseNumChildrento determine the valid index range.- Parameters:
index- theindexargument- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getChildWithAttr
Returns the child selected bytagPaththat also has an attribute namedattrNamewhose value exactly equalsattrValue. Tag paths: A tag path is Chilkat's|-separated child-navigation syntax, for exampletagA|tagB|tagC. It is not XPath.- Parameters:
tagPath- thetagPathargument (notnull)attrName- theattrNameargument (notnull)attrValue- theattrValueargument (notnull)- Returns:
- a new
Xmlowned by the caller, ornullif not found (no exception is thrown in that case); close it when done
-
getChildWithContent
Returns the first direct child whose text content exactly equalscontent. The child tag may be any value.- Parameters:
content- thecontentargument (notnull)- Returns:
- a new
Xmlowned by the caller, ornullif not found (no exception is thrown in that case); close it when done
-
getChildWithTag
Returns anXmlobject referencing the child selected bytagPath. The calling object remains positioned on its current element. Tag paths: A tag path is Chilkat's|-separated child-navigation syntax, for exampletagA|tagB|tagC. It is not XPath. Element-reference behavior: Methods that return anXmlobject return another object referencing an element in the same underlying tree. Methods whose names end in2instead move the caller's internal reference.- Parameters:
tagPath- thetagPathargument (notnull)- Returns:
- a new
Xmlowned by the caller, ornullif not found (no exception is thrown in that case); close it when done
-
getChildWithTag2
Moves the callingXmlobject's internal reference to the child selected bytagPath. Returnstruewhen the child is found and the move succeeds; otherwise returnsfalse. Tag paths: A tag path is Chilkat's|-separated child-navigation syntax, for exampletagA|tagB|tagC. It is not XPath. Element-reference behavior: Methods that return anXmlobject return another object referencing an element in the same underlying tree. Methods whose names end in2instead move the caller's internal reference.- Parameters:
tagPath- thetagPathargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getNthChildWithTag
Returns the zero-basednth direct child whose tag exactly equalstag. Children with other tag names are ignored when counting matches.Use
NumChildrenHavingTagto determine how many matching children are available.- Parameters:
tag- thetagargument (notnull)n- thenargument- Returns:
- a new
Xmlowned by the caller (nevernull); close it when done - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getNthChildWithTag2
Moves the callingXmlobject's internal reference to the zero-basednth direct child whose tag equalstag. Returnstrueon success andfalsewhen no such child exists. Element-reference behavior: Methods that return anXmlobject return another object referencing an element in the same underlying tree. Methods whose names end in2instead move the caller's internal reference.- Parameters:
tag- thetagargument (notnull)n- thenargument- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getParent
Returns anXmlobject referencing this element's parent. Returns no parent when the current element is the document root. Element-reference behavior: Methods that return anXmlobject return another object referencing an element in the same underlying tree. Methods whose names end in2instead move the caller's internal reference.- Returns:
- a new
Xmlowned by the caller, ornullif not found (no exception is thrown in that case); close it when done
-
getParent2
public void getParent2()Moves the callingXmlobject's internal reference to its parent. Returnstrueif a parent exists; otherwise returnsfalsewhen already at the root. Element-reference behavior: Methods that return anXmlobject return another object referencing an element in the same underlying tree. Methods whose names end in2instead move the caller's internal reference.- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getRoot
Returns anXmlobject referencing the root element of the XML tree that contains the current element. The calling object remains positioned on its current element. Element-reference behavior: Methods that return anXmlobject return another object referencing an element in the same underlying tree. Methods whose names end in2instead move the caller's internal reference.- Returns:
- a new
Xmlowned by the caller (nevernull); close it when done - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getRoot2
public void getRoot2()Moves the callingXmlobject's internal reference to the root element of its XML tree. Element-reference behavior: Methods that return anXmlobject return another object referencing an element in the same underlying tree. Methods whose names end in2instead move the caller's internal reference. -
getSelf
Returns a newXmlobject that references the same underlying XML element as the calling object. Shared element reference: This is not a deep copy. Both objects reference the same element, so changes made through either object are changes to the same XML tree.- Returns:
- a new
Xmlowned by the caller (nevernull); close it when done - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getXml
Serializes the XML tree or subtree rooted at the current element and returns the XML text.When called while positioned on the document root, the XML declaration is included if
EmitXmlDeclistrue. When called on a non-root element, only that subtree is emitted and the document declaration is not included.EmitCompact,Encoding,Standalone, and related document/output properties affect serialization as applicable.String vs. bytes: A language string is Unicode text. The
Encodingdeclaration describes serialized XML encoding, while actual byte encoding matters when XML is written to a file or byte-oriented destination.- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getXmlBd
Serializes the XML tree or subtree rooted at the current element and appends the encoded XML bytes tobd.The existing contents of the
BinDataobject are preserved. The XML output encoding is governed by the XML document's output settings, includingEncoding.Returns
trueon success andfalseon failure.- Parameters:
bd- thebdargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getXmlSb
Serializes the XML tree or subtree rooted at the current element and appends the resulting XML text tosb.The existing contents of
sbare preserved. Output properties such asEmitCompactandEmitXmlDeclapply as appropriate.Returns
trueon success andfalseon failure.- Parameters:
sb- thesbargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
hasAttrWithValue
Returnstrueif the calling element has an attribute namednamewhose value exactly equalsvalue; otherwise returnsfalse.- Parameters:
name- thenameargument (notnull)value- thevalueargument (notnull)- Returns:
- the result; this method never throws
ChilkatException
-
hasAttribute
Returnstrueif the calling element has an attribute namedname; otherwise returnsfalse.- Parameters:
name- thenameargument (notnull)- Returns:
- the result; this method never throws
ChilkatException
-
hasChildWithContent
Returnstrueif any direct child has text content exactly equal tocontent; otherwise returnsfalse.- Parameters:
content- thecontentargument (notnull)- Returns:
- the result; this method never throws
ChilkatException
-
hasChildWithTag
Returnstrueif the child selected bytagPathexists; otherwise returnsfalse. Tag paths: A tag path is Chilkat's|-separated child-navigation syntax, for exampletagA|tagB|tagC. It is not XPath.- Parameters:
tagPath- thetagPathargument (notnull)- Returns:
- the result; this method never throws
ChilkatException
-
hasChildWithTagAndContent
Returnstrueif the child selected bytagPathexists and its text content exactly equalscontent; otherwise returnsfalse. Tag paths: A tag path is Chilkat's|-separated child-navigation syntax, for exampletagA|tagB|tagC. It is not XPath.- Parameters:
tagPath- thetagPathargument (notnull)content- thecontentargument (notnull)- Returns:
- the result; this method never throws
ChilkatException
-
insertChildTreeAfter
Inserts the entire subtree referenced bytreeas a direct child immediately after the existing child at zero-basedindex.If
treebelongs to another XML document, the subtree is transferred to the destination tree.Structural move: The operation preserves the subtree structure. The supplied tree is not flattened into text content.
- Parameters:
index- theindexargumenttree- thetreeargument (notnull)
-
insertChildTreeBefore
Inserts the entire subtree referenced bytreeas a direct child immediately before the existing child at zero-basedindex.If
treebelongs to another XML document, the subtree is transferred to the destination tree.Structural move: The operation preserves the subtree structure. The supplied tree is not flattened into text content.
- Parameters:
index- theindexargumenttree- thetreeargument (notnull)
-
lastChild
Returns anXmlobject referencing the last direct child of the calling element.A common reverse-iteration pattern is
LastChildfollowed by repeated calls toPreviousSibling.Element-reference behavior: Methods that return an
Xmlobject return another object referencing an element in the same underlying tree. Methods whose names end in2instead move the caller's internal reference.- Returns:
- a new
Xmlowned by the caller, ornullif not found (no exception is thrown in that case); close it when done
-
lastChild2
public void lastChild2()Moves the callingXmlobject's internal reference to its last direct child. Returnstrueif a last child exists; otherwise returnsfalse. Element-reference behavior: Methods that return anXmlobject return another object referencing an element in the same underlying tree. Methods whose names end in2instead move the caller's internal reference.- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
loadBd
Parses XML from the bytes contained inbdand replaces the calling object's current XML tree with the loaded document.If
autoTrimistrue, leading and trailing whitespace is removed from each leaf element's text content during loading.Returns
trueon success andfalseon failure.- Parameters:
bd- thebdargument (notnull)autoTrim- theautoTrimargument- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
loadSb
Parses XML from the current contents ofsband replaces the calling object's current XML tree with the loaded document.If
autoTrimistrue, leading and trailing whitespace is removed from each leaf element's text content while loading.Returns
trueon success andfalseon failure.- Parameters:
sb- thesbargument (notnull)autoTrim- theautoTrimargument- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
loadXml
Parses the XML text inxmlDataand replaces the calling object's current XML tree content with the loaded document root. Returnstrueif parsing succeeds. Replacement operation: A successful load replaces the current document/tree state represented by this object; it does not append the loaded XML beneath the current element.- Parameters:
xmlData- thexmlDataargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
loadXml2
Parses the XML text inxmlDataand replaces the current XML tree, likeLoadXml. TheautoTrimargument additionally controls whether leading and trailing whitespace is removed from each leaf element's text content while loading. Whitespace significance: SetautoTrimtofalsewhen leading or trailing text whitespace is significant to the application.- Parameters:
xmlData- thexmlDataargument (notnull)autoTrim- theautoTrimargument- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
loadXmlFile
Reads and parses an XML document fromfileName, replacing the calling object's current XML tree with the loaded document root. Returnstrueon success.The file's XML declaration and byte encoding are used as part of normal XML parsing.
- Parameters:
fileName- thefileNameargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
loadXmlFile2
Reads and parses an XML document fromfileName, replacing the current XML tree. TheautoTrimargument controls whether leading and trailing whitespace is removed from each leaf element's text content. Whitespace significance: SetautoTrimtofalsewhen leading or trailing text whitespace must be preserved exactly.- Parameters:
fileName- thefileNameargument (notnull)autoTrim- theautoTrimargument- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
newChild
Creates and returns a new child attagPathwith the specified textcontent. A new child is created even when a child with the same tag already exists. Tag paths: A tag path is Chilkat's|-separated child-navigation syntax, for exampletagA|tagB|tagC. It is not XPath. Intermediate elements in a multi-part path are created as needed. UseFindOrAddNewChildwhen duplicate final children should be avoided.- Parameters:
tagPath- thetagPathargument (notnull)content- thecontentargument (notnull)- Returns:
- a new
Xmlowned by the caller (nevernull); close it when done - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
newChild2
Creates a new child attagPathwith the specified textcontent, but does not return a separateXmlobject for the new element. Tag paths: A tag path is Chilkat's|-separated child-navigation syntax, for exampletagA|tagB|tagC. It is not XPath. Intermediate elements in a multi-part path are created as needed.- Parameters:
tagPath- thetagPathargument (notnull)content- thecontentargument (notnull)
-
newChildAfter
Creates a new direct child with the specifiedtagandcontent, inserts it immediately after the child at zero-basedindex, and returns the new child element.- Parameters:
index- theindexargumenttag- thetagargument (notnull)content- thecontentargument (notnull)- Returns:
- a new
Xmlowned by the caller (nevernull); close it when done - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
newChildBefore
Creates a new direct child with the specifiedtagandcontent, inserts it immediately before the child at zero-basedindex, and returns the new child element.- Parameters:
index- theindexargumenttag- thetagargument (notnull)content- thecontentargument (notnull)- Returns:
- a new
Xmlowned by the caller (nevernull); close it when done - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
newChildInt2
Creates a new child attagPathwhose content is the decimal representation ofvalue. No separate child object is returned. Tag paths: A tag path is Chilkat's|-separated child-navigation syntax, for exampletagA|tagB|tagC. It is not XPath. Intermediate elements in a multi-part path are created as needed.- Parameters:
tagPath- thetagPathargument (notnull)value- thevalueargument
-
nextInTraversal2
Moves the callingXmlobject to the next element in a depth-first traversal of the tree and updatessbStatewith the traversal state.Pass an empty
StringBuilderwhen beginning a traversal, then reuse the samesbStatefor each subsequent call.Why the name ends in 2: This method changes the caller's internal element reference. There is no separate
NextInTraversalmethod that returns anotherXmlobject.- Parameters:
sbState- thesbStateargument (notnull)- Returns:
- the result; this method never throws
ChilkatException
-
nextSibling
Returns anXmlobject referencing the current element's next sibling, or no object when there is no next sibling. Element-reference behavior: Methods that return anXmlobject return another object referencing an element in the same underlying tree. Methods whose names end in2instead move the caller's internal reference.- Returns:
- a new
Xmlowned by the caller, ornullif not found (no exception is thrown in that case); close it when done
-
nextSibling2
public boolean nextSibling2()Moves the callingXmlobject's internal reference to its next sibling. Returnstrueif one exists; otherwise returnsfalse. Element-reference behavior: Methods that return anXmlobject return another object referencing an element in the same underlying tree. Methods whose names end in2instead move the caller's internal reference.- Returns:
- the result; this method never throws
ChilkatException
-
numChildrenAt
Returns the number of direct children of the element selected bytagPath. Returns-1if the path does not identify an existing element. Tag paths: A tag path is Chilkat's|-separated child-navigation syntax, for exampletagA|tagB|tagC. It is not XPath.- Parameters:
tagPath- thetagPathargument (notnull)- Returns:
- the result (see
ChilkatObject.getLastMethodSuccess()where the description mentions failure)
-
numChildrenHavingTag
Returns the number of direct children whose tag exactly equalstag. Descendants below those children are not included.- Parameters:
tag- thetagargument (notnull)- Returns:
- the result (see
ChilkatObject.getLastMethodSuccess()where the description mentions failure)
-
previousSibling
Returns anXmlobject referencing the current element's previous sibling, or no object when there is no previous sibling. Element-reference behavior: Methods that return anXmlobject return another object referencing an element in the same underlying tree. Methods whose names end in2instead move the caller's internal reference.- Returns:
- a new
Xmlowned by the caller, ornullif not found (no exception is thrown in that case); close it when done
-
previousSibling2
public void previousSibling2()Moves the callingXmlobject's internal reference to its previous sibling. Returnstrueif one exists; otherwise returnsfalse. Element-reference behavior: Methods that return anXmlobject return another object referencing an element in the same underlying tree. Methods whose names end in2instead move the caller's internal reference.- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
pruneAttribute
Recursively traverses the subtree rooted at the calling element and removes every occurrence of the attribute namedattrName.Returns the number of attributes removed.
- Parameters:
attrName- theattrNameargument (notnull)- Returns:
- the result (see
ChilkatObject.getLastMethodSuccess()where the description mentions failure)
-
pruneTag
Recursively traverses the subtree rooted at the calling element and removes every element whose tag equalstag. Each removed element's entire descendant subtree is removed with it.Returns the number of matching tag occurrences removed.
Subtree pruning: When a matching parent is removed, its descendants disappear as part of that subtree; this method is intended for structural cleanup rather than text-only removal.
- Parameters:
tag- thetagargument (notnull)- Returns:
- the result (see
ChilkatObject.getLastMethodSuccess()where the description mentions failure)
-
removeAllAttributes
public void removeAllAttributes()Removes every attribute from the calling element. Returnstrueon success.- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
removeAllChildren
public void removeAllChildren()Removes all direct child elements and their subtrees from the calling element. The calling element's own tag, attributes, and text content are retained. -
removeAttribute
Removes the attribute namednamefrom the calling element. Returnstruewhen the operation succeeds.- Parameters:
name- thenameargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
removeChild
Removes all child elements selected bytagPathbeneath the calling element. Tag paths: A tag path is Chilkat's|-separated child-navigation syntax, for exampletagA|tagB|tagC. It is not XPath. All matches: This method removes matching children rather than returning a removed subtree. Use anExtractChild...method when the removed element must be retained.- Parameters:
tagPath- thetagPathargument (notnull)
-
removeChildByIndex
public void removeChildByIndex(int index)Removes the direct child at zero-basedindex, including that child's entire subtree.- Parameters:
index- theindexargument
-
removeChildWithContent
Removes all direct children whose text content exactly equalscontent, including each removed child's subtree.- Parameters:
content- thecontentargument (notnull)
-
removeFromTree
public void removeFromTree()Detaches the calling element and its entire subtree from its parent. The detached element becomes the root of its own independent XML tree. Object remains usable: This method removes the subtree from its former document but keeps the callingXmlobject referencing the detached subtree. -
removeStyleSheet
Removes XML stylesheet processing instructions whose attribute namedattrNamehas the valueattrValue.Returns the number of matching stylesheet declarations removed, or
-1if an error occurs.- Parameters:
attrName- theattrNameargument (notnull)attrValue- theattrValueargument (notnull)- Returns:
- the result (see
ChilkatObject.getLastMethodSuccess()where the description mentions failure)
-
saveBinaryContent
public void saveBinaryContent(String filename, boolean unzipFlag, boolean decryptFlag, String password)Decodes the binary content stored in this element and writes the resulting bytes tofilename. SetunzipFlaganddecryptFlagto reverse the transformations originally applied, and supply the correspondingpasswordwhen decrypting.Returns
trueon success andfalseon failure.- Parameters:
filename- thefilenameargument (notnull)unzipFlag- theunzipFlagargumentdecryptFlag- thedecryptFlagargumentpassword- thepasswordargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
saveXml
Serializes the XML tree or subtree rooted at the current element and writes it tofileName.Document/output properties such as
Encoding,EmitBom,EmitXmlDecl, andEmitCompactaffect the generated output as applicable.Returns
trueon success andfalseon failure.- Parameters:
fileName- thefileNameargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
scrub
Recursively normalizes the XML subtree rooted at the calling element according to the comma-separated keywords indirectives.Supported directives are:
AttrTrimEnds- remove leading and trailing whitespace from attribute values.AttrTrimInside- replace tabs, CR, and LF with spaces and collapse repeated spaces inside attribute values.ContentTrimEnds- remove leading and trailing whitespace from element content.ContentTrimInside- normalize internal tabs/line breaks/spaces in element content.LowercaseAttrs- convert attribute names to lowercase.LowercaseTags- convert tag names to lowercase.RemoveCtrl- remove US-ASCII control characters with values 0-31 except TAB, CR, and LF.
Destructive normalization: Scrubbing modifies the tree. Use these options only when the corresponding whitespace, letter case, or control characters are not semantically significant to the application.
- Parameters:
directives- thedirectivesargument (notnull)
-
searchAllForContent
Returns the first element whose text content matchescontentPattern, regardless of tag name.The search is breadth-first within the subtree rooted at the caller. The
afterPtrargument identifies the element after which matching should begin, allowing repeated calls to continue an iteration. To begin at the first candidate, usenullwhere the language binding permits it; ActiveX callers should pass a reference to the caller's element instead.Wildcard patterns are case-sensitive and may contain
*, where each asterisk matches zero or more characters.Iteration: Pass the element returned by one call as
afterPtron the next call to continue to the next match. Continue until no further element is returned.- Parameters:
after- theafterPtrargument (may benull)contentPattern- thecontentPatternargument (notnull)- Returns:
- a new
Xmlowned by the caller, ornullif not found (no exception is thrown in that case); close it when done
-
searchAllForContent2
Performs the same breadth-first content search asSearchAllForContent, but moves the callingXmlobject's internal reference to the matching element instead of returning a separate element object.The search is breadth-first within the subtree rooted at the caller. The
afterPtrargument identifies the element after which matching should begin, allowing repeated calls to continue an iteration. To begin at the first candidate, usenullwhere the language binding permits it; ActiveX callers should pass a reference to the caller's element instead.Wildcard patterns are case-sensitive and may contain
*, where each asterisk matches zero or more characters.Element-reference behavior: Methods that return an
Xmlobject return another object referencing an element in the same underlying tree. Methods whose names end in2instead move the caller's internal reference.- Parameters:
after- theafterPtrargument (may benull)contentPattern- thecontentPatternargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
searchForAttribute
Returns the first element whose tag equalstag, that has an attribute namedattr, and whose attribute value matchesvaluePattern.The search is breadth-first within the subtree rooted at the caller. The
afterPtrargument identifies the element after which matching should begin, allowing repeated calls to continue an iteration. To begin at the first candidate, usenullwhere the language binding permits it; ActiveX callers should pass a reference to the caller's element instead.Wildcard patterns are case-sensitive and may contain
*, where each asterisk matches zero or more characters.Iteration: Pass the previous match as
afterPtrto continue searching after that element.- Parameters:
after- theafterPtrargument (may benull)tag- thetagargument (notnull)attr- theattrargument (notnull)valuePattern- thevaluePatternargument (notnull)- Returns:
- a new
Xmlowned by the caller, ornullif not found (no exception is thrown in that case); close it when done
-
searchForAttribute2
Performs the same breadth-first tag/attribute search asSearchForAttribute, but moves the callingXmlobject's internal reference to the matching element instead of returning a separate object.The search is breadth-first within the subtree rooted at the caller. The
afterPtrargument identifies the element after which matching should begin, allowing repeated calls to continue an iteration. To begin at the first candidate, usenullwhere the language binding permits it; ActiveX callers should pass a reference to the caller's element instead.Wildcard patterns are case-sensitive and may contain
*, where each asterisk matches zero or more characters.Element-reference behavior: Methods that return an
Xmlobject return another object referencing an element in the same underlying tree. Methods whose names end in2instead move the caller's internal reference.- Parameters:
after- theafterPtrargument (may benull)tag- thetagargument (notnull)attr- theattrargument (notnull)valuePattern- thevaluePatternargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
searchForContent
Returns the first element whose tag equalstagand whose text content matchescontentPattern.The search is breadth-first within the subtree rooted at the caller. The
afterPtrargument identifies the element after which matching should begin, allowing repeated calls to continue an iteration. To begin at the first candidate, usenullwhere the language binding permits it; ActiveX callers should pass a reference to the caller's element instead.Wildcard patterns are case-sensitive and may contain
*, where each asterisk matches zero or more characters.Iteration: Pass the previous match as
afterPtrto continue searching after that element.- Parameters:
after- theafterPtrargument (may benull)tag- thetagargument (notnull)contentPattern- thecontentPatternargument (notnull)- Returns:
- a new
Xmlowned by the caller, ornullif not found (no exception is thrown in that case); close it when done
-
searchForContent2
Performs the same breadth-first tag/content search asSearchForContent, but moves the callingXmlobject's internal reference to the matching element.The search is breadth-first within the subtree rooted at the caller. The
afterPtrargument identifies the element after which matching should begin, allowing repeated calls to continue an iteration. To begin at the first candidate, usenullwhere the language binding permits it; ActiveX callers should pass a reference to the caller's element instead.Wildcard patterns are case-sensitive and may contain
*, where each asterisk matches zero or more characters.Element-reference behavior: Methods that return an
Xmlobject return another object referencing an element in the same underlying tree. Methods whose names end in2instead move the caller's internal reference.- Parameters:
after- theafterPtrargument (may benull)tag- thetagargument (notnull)contentPattern- thecontentPatternargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
searchForTag
Returns the first element whose tag exactly equalstag.The search is breadth-first within the subtree rooted at the caller.
afterPtridentifies the element after which searching begins. To begin at the first candidate, usenullwhere the language binding permits it; ActiveX callers should pass a reference to the caller's element.Iteration: Pass the previous match as
afterPtrto find the next matching tag. Continue until no further element is returned.- Parameters:
after- theafterPtrargument (may benull)tag- thetagargument (notnull)- Returns:
- a new
Xmlowned by the caller, ornullif not found (no exception is thrown in that case); close it when done
-
searchForTag2
Performs the same breadth-first tag search asSearchForTag, but moves the callingXmlobject's internal reference to the matching element instead of returning a separate object.Use
afterPtrin the same way as withSearchForTagto begin or continue the search.Element-reference behavior: Methods that return an
Xmlobject return another object referencing an element in the same underlying tree. Methods whose names end in2instead move the caller's internal reference.- Parameters:
after- theafterPtrargument (may benull)tag- thetagargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
setBinaryContentBd
public void setBinaryContentBd(BinData data, boolean zipFlag, boolean encryptFlag, String password)Stores the bytes indataas binary content on this element, with optional ZIP compression and optional password-based AES encryption. The stored binary representation is emitted as Base64 text when XML is serialized.If
zipFlagistrue, the bytes are compressed first. IfencryptFlagistrue, the data is encrypted using Chilkat's 128-bit Rijndael/AES format andpassword.Returns
trueon success andfalseon failure.Round trip: Use the corresponding binary-content retrieval methods with matching decompression/decryption options to recover the original bytes.
- Parameters:
data- thedataargument (notnull)zipFlag- thezipFlagargumentencryptFlag- theencryptFlagargumentpassword- thepasswordargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
setBinaryContentFromFile
public void setBinaryContentFromFile(String filename, boolean zipFlag, boolean encryptFlag, String password)Reads the bytes fromfilenameand stores them as this element's binary content, with optional ZIP compression and optional password-based encryption. The resulting stored data is represented as Base64 when XML text is generated.Returns
trueon success andfalseon failure.- Parameters:
filename- thefilenameargument (notnull)zipFlag- thezipFlagargumentencryptFlag- theencryptFlagargumentpassword- thepasswordargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
sortByAttribute
Sorts the calling element's direct children by the string value of attributeattrName. Setascendingtotruefor ascending order orfalsefor descending order.SortCaseInsensitivecontrols case sensitivity for string sorting.- Parameters:
attrName- theattrNameargument (notnull)ascending- theascendingargument
-
sortByAttributeInt
Sorts the calling element's direct children numerically by the value of attributeattrName, interpreting each sort value as an integer rather than comparing the text lexicographically.Set
ascendingtotruefor ascending order orfalsefor descending order.- Parameters:
attrName- theattrNameargument (notnull)ascending- theascendingargument
-
sortByContent
public void sortByContent(boolean ascending)Sorts the calling element's direct children by their text content. Setascendingtotruefor ascending order orfalsefor descending order.SortCaseInsensitivecontrols case sensitivity for the string comparison.- Parameters:
ascending- theascendingargument
-
sortByTag
public void sortByTag(boolean ascending)Sorts the calling element's direct children by tag name. Setascendingtotruefor ascending order orfalsefor descending order.SortCaseInsensitivecontrols case sensitivity for the tag-name comparison.- Parameters:
ascending- theascendingargument
-
sortRecordsByAttribute
Treats each direct child as a record and sorts those records by the value of attributeattrNameon the record's child identified bysortTag.Set
ascendingtotruefor ascending order orfalsefor descending order. String comparisons honorSortCaseInsensitive.- Parameters:
sortTag- thesortTagargument (notnull)attrName- theattrNameargument (notnull)ascending- theascendingargument
-
sortRecordsByContent
Treats each direct child as a record and sorts those records by the text content of the record's child namedsortTag.Set
ascendingtotruefor ascending order orfalsefor descending order. String comparisons honorSortCaseInsensitive.- Parameters:
sortTag- thesortTagargument (notnull)ascending- theascendingargument
-
sortRecordsByContentInt
Treats each direct child as a record and sorts those records numerically by the integer content of the record's child namedsortTag.Numeric comparison is used instead of lexicographic string comparison. Set
ascendingtotruefor ascending order orfalsefor descending order.- Parameters:
sortTag- thesortTagargument (notnull)ascending- theascendingargument
-
swapNode
Swaps the calling element's tag, text content, and attributes with those ofnode.Returns
trueon success andfalseon failure.Children are not swapped: Use
SwapTreewhen child subtrees should also be exchanged.- Parameters:
node- thenodeargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
swapTree
Swaps the calling element's complete tree state withtree, including tag, text content, attributes, and children.Returns
trueon success andfalseon failure.- Parameters:
tree- thetreeargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
tagContent
Searches the subtree rooted at the calling element for the first element whose tag equalstagNameand returns that element's text content. Recursive search: Unlike direct-child getters, this search is not limited to the caller's immediate children.- Parameters:
tagName- thetagNameargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
tagEquals
Returnstrueif the calling element's complete tag name, including any namespace prefix, exactly equalstag; otherwise returnsfalse.- Parameters:
tag- thetagargument (notnull)- Returns:
- the result; this method never throws
ChilkatException
-
tagIndex
Returns the zero-based child index of the element selected bytagPath. Returns-1when no matching element is found at that path. Tag paths: A tag path is Chilkat's|-separated child-navigation syntax, for exampletagA|tagB|tagC. It is not XPath. Index meaning: The returned index is the element's position among its parent's direct children, which is the index accepted by methods such asGetChild,RemoveChildByIndex, and the insertion methods.- Parameters:
tagPath- thetagPathargument (notnull)- Returns:
- the result (see
ChilkatObject.getLastMethodSuccess()where the description mentions failure)
-
tagNsEquals
Returnstrueif this element's namespace-prefix portion exactly equalsns; otherwise returnsfalse.For example, the namespace prefix of
soapenv:Bodyissoapenv.Prefix comparison: This compares the lexical prefix, not the namespace URI bound to that prefix.
- Parameters:
ns- thensargument (notnull)- Returns:
- the result; this method never throws
ChilkatException
-
tagUnpEquals
Returnstrueif this element's unprefixed tag exactly equalsunprefixedTag; otherwise returnsfalse.For example, the unprefixed tag of
soapenv:BodyisBody.- Parameters:
unprefixedTag- theunprefixedTagargument (notnull)- Returns:
- the result; this method never throws
ChilkatException
-
unzipContent
public void unzipContent()ReversesZipContent: decodes and decompresses the calling element's compressed content and replaces the stored Base64-compressed representation with the original content.Returns
trueon success andfalseon failure.- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
unzipTree
public void unzipTree()ReversesZipTree: decompresses the stored representation and reconstructs the calling element's previously compressed subtree.The element's tag and attributes, which are not replaced by
ZipTree, remain associated with the restored tree.Returns
trueon success andfalseon failure.- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
updateAt
Sets the text content of the element selected bytagPathtovalue.If
autoCreateistrue, missing elements along the path are created as needed. If it isfalse, the update requires the target path to already exist.Tag paths: A tag path is Chilkat's
|-separated child-navigation syntax, for exampletagA|tagB|tagC. It is not XPath.- Parameters:
tagPath- thetagPathargument (notnull)autoCreate- theautoCreateargumentvalue- thevalueargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
updateAttrAt
Sets attributeattrNametoattrValueon the element selected bytagPath. The attribute is added when it does not already exist.If
autoCreateistrue, missing elements along the path are created as needed. If it isfalse, the target path must already exist.Tag paths: A tag path is Chilkat's
|-separated child-navigation syntax, for exampletagA|tagB|tagC. It is not XPath.- Parameters:
tagPath- thetagPathargument (notnull)autoCreate- theautoCreateargumentattrName- theattrNameargument (notnull)attrValue- theattrValueargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
updateAttribute
Sets attributeattrNametoattrValue. If the attribute already exists its value is replaced; otherwise the attribute is added.Returns
trueon success andfalseon failure.- Parameters:
attrName- theattrNameargument (notnull)attrValue- theattrValueargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
updateAttributeInt
Sets attributeattrNameto the decimal representation of integervalue. UseUpdateAttributefor string values.Returns
trueon success andfalseon failure.- Parameters:
attrName- theattrNameargument (notnull)value- thevalueargument- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
updateChildContent
Sets the text content of the child selected bytagPathtovalue. Missing elements along the path are automatically created as needed. Tag paths: A tag path is Chilkat's|-separated child-navigation syntax, for exampletagA|tagB|tagC. It is not XPath.- Parameters:
tagPath- thetagPathargument (notnull)value- thevalueargument (notnull)
-
updateChildContentInt
Sets the content of the child selected bytagPathto the decimal representation of integervalue. Tag paths: A tag path is Chilkat's|-separated child-navigation syntax, for exampletagA|tagB|tagC. It is not XPath.- Parameters:
tagPath- thetagPathargument (notnull)value- thevalueargument
-
zipContent
public void zipContent()ZIP-compresses this element's text content and replaces the original content with Base64-encoded compressed data.Returns
trueon success andfalseon failure.Reversible transformation: Call
UnzipContentto restore the original content.- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
zipTree
public void zipTree()ZIP-compresses the calling element's content together with its entire child subtree and replaces that structure with Base64-encoded compressed data.The calling element's tag and attributes are not changed. Call
UnzipTreeto reconstruct the compressed subtree.Returns
trueon success andfalseon failure.- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-