# TextForAttribute(MarkupAttribute)

Method in [MarkupParseResult](https://docs.yarnspinner.dev/3.1/api/csharp/yarn.markup/yarn.markup.markupparseresult)

## Summary

Returns the substring of [Text](https://docs.yarnspinner.dev/3.1/api/csharp/yarn.markup/yarn.markup.markupparseresult/yarn.markup.markupparseresult.text) covered by `attribute` Position and Length properties.

```csharp
public readonly string TextForAttribute(MarkupAttribute attribute)
```

## Remarks

If the attribute's [Length](https://docs.yarnspinner.dev/3.1/api/csharp/yarn.markup/yarn.markup.markupattribute/yarn.markup.markupattribute.length) property is zero, this method returns the empty string.

This method does not check to see if `attribute` is an attribute belonging to this MarkupParseResult. As a result, if you pass an attribute that doesn't belong, it may describe a range of text that does not appear in [Text](https://docs.yarnspinner.dev/3.1/api/csharp/yarn.markup/yarn.markup.markupparseresult/yarn.markup.markupparseresult.text). If this occurs, an `System.IndexOutOfRangeException` will be thrown.

## Parameters

| Name                                                                                                                         | Description                        |
| ---------------------------------------------------------------------------------------------------------------------------- | ---------------------------------- |
| [Yarn.Markup.MarkupAttribute](https://docs.yarnspinner.dev/3.1/api/csharp/yarn.markup/yarn.markup.markupattribute) attribute | The attribute to get the text for. |

## Returns

The text contained within the attribute.
