Jump to content

mmm xml info to query a file?


fastmouse

Recommended Posts

Hi all,

 

Im new to the Php world only just having done a 2 day course. Problem I have is my boss expects me to know everything! and to be honest PHP confused me a bit and the book I recieved with the course was rubbish!

 

Anyway heres what the boss wants me to do by monday!

 

I need to read in an xml file;

 

$file = "chart_data.xml";  (is this right?)

 

then I need to extract a FileName contained as one of the elements heres an eg. of my xml:

 

<charts>

<AirField>

  <name>CYYT ST JOHNS NFLD</name>

  <Plate>

  <Title>CENTRAL DE-ICING FACILITY</Title>

  <FileName>CYYTF1</FileName>

  </Plate>

  <Plate>

  <Title>BURIN 8 (LEXAK,BURIN 8) RNAV STAR</Title>

  <FileName>CYYTH2</FileName>

  </Plate>

  <Plate>

  <Title>NDB RWY 29</Title>

  <FileName>CYYTP2</FileName>

  </Plate>

  </AirField>

</charts>

 

I need to then use the info used within the <FileName> tag and use it to search a folder containing PDFs and see if the required file is there?

 

do I use the Is_file command?

 

I then need it to produce a text file of all the missing files?

 

I may be using the wrong technology here, but it seemed possible to do? basicaly parse the filename add the extention have it look for the full name in the folder if false return a list of "False" file names?

 

Ive spent 3 days on this now and havent got anywhere! im thinking of looking for another course!

 

If anyone understands what im on about :)  please explain what I have to do as im lost! If you can supply some code for me to learn from it would be handy also!

 

thanks

Mike

Link to comment
Share on other sites

hi Mike.

 

As far as i understand you. You need to:

 

1- Get a XML File and retrieve the filename value(s)

2- Search if the filename.pdf file exists

3- Generate a file of all non-existent pdf files within xml.

 

Lets start.

$file = "chart_data.xml";  (is this right?)

 

No, with that code you are only assigning the string value to the variable $file. You are not reading the xml file..  ::)

 

1 - To read the xml file is neccesary to use functions like fopen("chart_data.xml","r+") and then parse the data in the file ( Read about PHP File handling ) .

Fortunately, there are a lot of functions on the web and information to parse xml information from a given file (Search at google php xml parse )

2-  Once you have the filename, use the php function file_exist("some_file.pdf"). it returns true if exists or false if not.

3- When you check for the file existance, you can create a file fopen("non-existent-files.txt","w+").

 

hope this helps, gl

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.