Home > Net >  How to parse xml string?
How to parse xml string?

Time:01-18

I am trying to set String to the TextView. But response which I getting is like <?xml version="1.0" encoding="utf-8"?> <string xmlns="http://tempuri.org/">"Fortune Life"</string>

So it takes full string from xml to string but I want only double quoted content.i.e.,"Fortune Life" What to do to parse xml string?

CodePudding user response:

<?xml version="1.0" encoding="utf-8"?> 
<string name="WebsiteTitle">"Fortune Life"</string>
<string name="WebsiteURL">"http://tempuri.org/"</string>

Then you can use string as R.string.WebsiteTitle or R.string.WebsiteURL. To use string in TextView use android:text = "@string/WebsiteTitle" or android:text = "@string/WebsiteURL"

CodePudding user response:

Well You Need to go to res > values > String.xml

you need to set your String in String.xml

enter image description here

enter image description here

In above image you need go to String xml

<resources>
<string name="app_name">DocumentRecord</string>
<string name="your_title">your title</string>
<string name="your_url"><a href="your_website"></a></string></resources>
  •  Tags:  
  • Related