User Tools

Site Tools


modding:function:xmlgettext

Discuss this page

xmlGetText

Syntax (xmlGetText xml index) → xml
Arguments xml: The XML element to get the text data from
index: The 0-based index of the text to get
Returns The block of text at the specified index in xml
Category XML
Description “Text” refers to whatever is not part of the XML tags or subelements. This includes the TLisp code contained inside Event elements. Indexes are separated by subelements

Explanation

Consider the following XML data:

	<Type UNID="&unidHugoSandoval;">
		<StaticData>
			<Data id="MissionAttribute">"hugoSandovalMission"</Data>
			<Data id="Name">"Hugo Sandoval"</Data>
			<Data id="Sovereign">&svCommonwealth;</Data>
		</StaticData>

		<Events>
			<OnCharacterCanBeMet>
				True
			</OnCharacterCanBeMet>

			<OnGlobalSystemStopped>
				(rpgCharacterAscend &unidHugoSandoval;)
			</OnGlobalSystemStopped>
		</Events>
	</Type>

Now consider the following code:

	(block (theXML theXMLText0 theXMLText1 theXMLText2 theStaticData theDataText0 theDataText1 theDataText2)
		(setq theXML (typGetXML &unidHugoSandoval;))

		(setq theXMLText0 (xmlGetText theXML 0))
		(setq theXMLText1 (xmlGetText theXML 1))
		(setq theXMLText2 (xmlGetText theXML 2))
		
		(setq theStaticData (xmlGetSubElement theXML 'StaticData))
		(setq theDataText0 (xmlGetText (xmlGetSubElement theStaticData 0) 0))
		(setq theDataText1 (xmlGetText (xmlGetSubElement theStaticData 1) 0))
		(setq theDataText2 (xmlGetText (xmlGetSubElement theStaticData 2) 0))
		)
  • theXML is equal to the XML defined above.
  • theXMLText0 is the space between <Type UNID=“&unidHugoSandoval;”> and <StaticData>
  • theXMLText1 is the space between </StaticData> and <Events>
  • theXMLText2 is the space between </Events> and </Type>
  • theDataText0 is “hugoSandovalMission”
  • theDataText1 is “Hugo Sandoval”
  • theDataText2 is &svCommonwealth;

XML

Return to XML Functions list

Return to Functions list

modding/function/xmlgettext.txt · Last modified: 2017/01/28 19:54 by 0xabcdef