Unfortunately, you're asking how to screw in a light bulb with a hammer. You might be able to get the job done with the hammer, but it's more likely the bulb will end up shattered. You should should be asking what better tools there are for changing light bulbs.
/metaphor
You should probably be using XPathDocument and XPathExpression to test this XML fragment for the conditions you're looking for.
I've tossed the fragment you've shared along with some similar elements into a file xpathfragment.xml:
<?xml version="1.0"?><xml>
<para styleclass="NOT Table Row Heading Text">some text<text style="font-size:12pt;">iso.otherstuffthings</text>other text></para>
<para styleclass="Table Row Heading Text">some text<text style="font-size:12pt;">iso.outgoingQueueNameas</text>some text</para>
<para styleclass="Table Row Heading Text">some text<text style="font-size:18pt;">iso.outgoingQueueNameas</text>some text</para>
</xml>
The following PowerShell script does what I think you're trying to do:
find the inner-text of <text>
elements having 'style' attribute equal to 'font-size:12pt', and whose immediate parent is a <para>
element with 'styleclass' equal to 'Table Row Heading Text'
$filename = "c:\users\Username\Documents\xpathfragment.xml"
$xpDoc = [System.Xml.XPath.XPathDocument] $filename
$xpDocNavigator = $xpDoc.CreateNavigator()
$xpPathExpression = "/xml/para[@styleclass='Table Row Heading Text']/text[@style='font-size:12pt;']"
$xpDocNavigator.Evaluate($xpPathExpression)
This returns a single result from the test xml:
Value : iso.outgoingQueueNameas
NodeType : Element
LocalName : text
NamespaceURI :
Name : text
Prefix :
BaseURI : file:///c:/users/Username/Documents/xpathfragment.xml
IsEmptyElement : False
NameTable : System.Xml.NameTable
HasAttributes : True
HasChildren : True
UnderlyingObject : iso.outgoingQueueNameas
LineNumber : 3
LinePosition : 53
IsNode : True
XmlType :
TypedValue : iso.outgoingQueueNameas
ValueType : System.String
ValueAsBoolean :
ValueAsDateTime :
ValueAsDouble :
ValueAsInt :
ValueAsLong :
XmlLang :
SchemaInfo :
CanEdit : False
OuterXml : <text style="font-size:12pt;">iso.outgoingQueueNameas</text>
InnerXml : iso.outgoingQueueNameas
The Value attribute iso.outgoingQueueNameas
is, I think, what you wanted to find.
You'll need to fashion your xpath query to work within the context of the xml document you're using, but the above should be enough to get you started. You'll have a bit of learning curve picking up the xpath syntax, but in the end you'll have understanding of a tool that is much better suited to xml searching.