0

Hi so i have a little problem i have an xml file i need to read all the data from but i am not good with xml

i have google it and found out ways to get normal xml files but the thing is i dont know how to go about getting the xml file i need i will place a small copy of it below

    <items>
    <batch>
    <id>1</id>
    <subatch>
    <tracking>110f6ty</tracking>
    <name>toysrus-package-110f6ty</name>
    <location>glasgow</location>
    </subatch>
    <subatch>
    <tracking>110f6ty</tracking>
    <name>toysrus-package-110f6ty</name>
    <location>glasgow</location>
    </subatch>
    </batch>

    <batch>
    <id>2</id>
    <subatch>
    <tracking>110f6ty</tracking>
    <name>toysrus-package-110f6ty</name>
    <location>glasgow</location>
    </subatch>
    <subatch>
    <tracking>110f6ty</tracking>
    <name>toysrus-package-110f6ty</name>
    <location>glasgow</location>
    </subatch>
    </batch>
    </items>

How would i go about getting eatch "Batch" by its id then then getting each "Subatch" inside this batch and then eching out the contents of each "Subatch" in the following format

    tracking -> name -> location

thanks for any help and i am sorry if there are spelling mistakes i suffer from dyslexia

  • you do relise this does not help anyone at all you sending someone to a page full of tech talk and code that has all ready stated they are not good with it i need it to be xml phrasing also not html dom – kid kodi Oct 16 '15 at 14:23
  • Parsing HTML or XML is (almost) the same thing. It's parsing markup. In most cases, you can even use `SimpleXMLElement` and `DOMDocument` on both HTML and XML, and it wouldn't make a big difference. I personally tend to prefer `DOMDocument` for both XML and HTML. Markup is markup, and if you want to traverse nodes, either one will do – Elias Van Ootegem Oct 16 '15 at 14:25
  • Besides: read through the firs answer: It talks about HTML _and_ XML, not just HTML. Lastly: If you don't like to be linked to a page that **contains the info you need to write the code you need** hire a dev to write the code for you. Don't expect a copy-paste answer for free here – Elias Van Ootegem Oct 16 '15 at 14:27
  • If you're looking for a simple way to query the DOM for elements with attribute id set to a specific value, the RTFM. If you want to know how to iterate nodes (`foreach` or otherwise): RTFM. It's all there. If that _"overpowers"_ your brain, then take a break, calm down, read the manual and try some stuff first. The marked duplicate isn't _"shit"_, it's very much relevant to your question, just ***read*** it – Elias Van Ootegem Oct 16 '15 at 15:05
  • There's no need for obscenities, please take some time to calm down. You will get flagged, and possibly end up being banned or temporarily suspended. Perhaps consider reading through the [help centre](http://stackoverflow.com/help), it probably says something about _"not being offensive or rude"_ somewhere – Elias Van Ootegem Oct 16 '15 at 15:21

0 Answers0