0

I'm working with the strings.xml file that is prepared according to google's translate services, which specifies that portions of your string that you don't want translated should be wrapped in a xliff:g tag like this: <xliff:g>some text</xliff:g>

for example, my strings.xml file

<?xml version="1.0" encoding="UTF-8"?>
<resources xmlns:xliff="rn:oasis:names:tc:xliff:document:1.2">
    <string name="game_starts_now">Game Starts Now</string>
    <string name="game_starts_in">Game Starts In <xliff:g id="seconds" example="20">{0}</xliff:g> seconds</string>
</resources>

if I trace out the first value by searching for the name "game_starts_now", it traces out as expected, but if i trace out "game_starts_in" it gives the full xml node that it exists in.

example:

trace((xml.string.(@name == "game_starts_now"))); // Game Starts Now
trace((xml.string.(@name == "game_starts_in"))); // [output is next 4 lines]
// <string name="game_starts_in" xmlns:xliff="rn:oasis:names:tc:xliff:document:1.2">
//  Game Starts In
//  <xliff:g id="seconds" example="20">{0}</xliff:g>
// </string>

Is there a way to get the full inner text of the <string> without child nodes? I'd like to have the 2nd trace output the following text:

Game Starts In {0} seconds

  • Try `trace((xml.string.(@name == "game_starts_in")).text())` but you will get : `Game Starts Inseconds`. – akmozo Dec 07 '14 at 21:17

1 Answers1

0

The way to access child nodes of XML is by using dot notation like you would with any normal object. I would try using trace((xml.string.(@ == "game_starts_in").(@id =="seconds")));

Let me know if this works for you.