I’m using C#. I have a web page that is in XML format (though you do not see the format in the actual URL).
Example:
…./api/rest/v1/items/ZPA
Part of the page (the part I care about looks something like this):
<Identifiers>
<Identifier name="v" value="zzzz"/>
<Identifier name="id" value="29382bb53cc73af32153276fe0a6cd6c"/>
<Identifier name="qn" value="wyz-zz1"/>
<Identifier name="index" value="1111"/>
<Identifier name="item" value="ZPA"/>
</Identifiers>
I need to read this from the web, and grab the “id” value. How would I go about doing this? The id value in this case would be “zzzz.” I need to grab it and store it in a variable.
This assumes that you want to be able to target one of the Identifier nodes by name, and that you are sure that there will be an element WITH that name. If that is not true, then the .Single call will throw an Exception if that node is not found.
If you needed to use credentials and wanted to use a WebClient, then you could use the following:
(Note, I have done no exception handling, checking for stream availability, or otherwise disposed/closed the streams, just an example of how to get it to “work”)